Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 水印使用John Myczek';s级_C#_Wpf_Watermark - Fatal编程技术网

C# 水印使用John Myczek';s级

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

嘿,我试着实现约翰做的一个类

我被困住了,不知道是否有人能帮助我。。。。添加了提到的2个类 在wpf上:

<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创建边距并将其移动到所需位置
  • 边距和对齐螺钉与显示水印的位置对齐

我尝试了这个例子,它对我很有效

然而,我确实注意到以下几点:

这些类没有指定名称空间,所以我为这两个类都添加了一个名称空间。在我的例子中是“水印”

WatermarkAdorner类位于“internal”中,但除非它位于不同的程序集(dll)中,否则这不会影响您。如果是,则将其“公开”

然后在xaml中,我添加了一个名称空间声明

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);
  }
}