C# 水印使用John Myczek';s级
嘿,我试着实现约翰做的一个类 我被困住了,不知道是否有人能帮助我。。。。添加了提到的2个类 在wpf上:C# 水印使用John Myczek';s级,c#,wpf,watermark,C#,Wpf,Watermark,嘿,我试着实现约翰做的一个类 我被困住了,不知道是否有人能帮助我。。。。添加了提到的2个类 在wpf上: <AdornerDecorator> <ComboBox Height="23" HorizontalAlignment="Right" Margin="0,184,664,0" x:Name="cbVideoDevices" VerticalAlignment="Top" Width="316" Initialized="cbVideoDevices_In
<AdornerDecorator>
<ComboBox Height="23" HorizontalAlignment="Right" Margin="0,184,664,0" x:Name="cbVideoDevices" VerticalAlignment="Top" Width="316" Initialized="cbVideoDevices_Initialized" SelectionChanged="cbVideoDevices_SelectionChanged">
<Controls:WatermarkService.Watermark>
<TextBlock>Type here to search text</TextBlock>
</Controls:WatermarkService.Watermark>
</ComboBox>
</AdornerDecorator>
在此处键入以搜索文本
无论我尝试什么,都会不断出错,因为控件不存在,或者属性不存在。我在他的类中没有错误,所以我认为引用是好的,但在我看来System.Windows.Control丢失了。。。。但我找不到它来添加它
任何帮助,非常感谢
编辑:在利兹的帮助下,我让这个工作,但让任何人知道,谁使用这个
- AdorneDecorator会在所有内容上创建一个框
- 为AdorneDecorator创建边距并将其移动到所需位置
- 边距和对齐螺钉与显示水印的位置对齐
xmlns:Controls="clr-namespace:Watermark"
在那一点上,一切都很顺利
我的稍微简化的xaml如下所示:
<AdornerDecorator >
<ComboBox Height="23" x:Name="cbVideoDevices"
Initialized="cbVideoDevices_Initialized"
SelectionChanged="cbVideoDevices_SelectionChanged">
<controls:WatermarkService.Watermark>
<TextBlock>Type here to search text</TextBlock>
</controls:WatermarkService.Watermark>
</ComboBox>
</AdornerDecorator>
我不知道xmlns,所以我添加了它。。。这就是它现在的样子
xmlns:Controls=“clr namespace:VideoCapture”
在此处键入以搜索文本
,但仍然获取错误控件的是未声明的前缀,并且在类型WatermarkServiceNvm中未找到可附加的属性水印,只是vs2010有点暴躁,我现在没有收到任何错误,谢谢,但仍然没有显示,我会尝试找出答案。在wpf真的很新:P汉克斯,它和一个新的文本框一起工作,我得弄清楚为什么我的旧文本框不工作。
<AdornerDecorator >
<ComboBox Height="23" x:Name="cbVideoDevices"
Initialized="cbVideoDevices_Initialized"
SelectionChanged="cbVideoDevices_SelectionChanged">
<controls:WatermarkService.Watermark>
<TextBlock>Type here to search text</TextBlock>
</controls:WatermarkService.Watermark>
</ComboBox>
</AdornerDecorator>
private static void Control_Loaded(object sender,RoutedEventArgs e)
{
Control control = (Control)sender;
if(ShouldShowWatermark(control))
{
ShowWatermark(control);
}
else
{
RemoveWatermark(control);
}
}