Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.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
Wpf 将元素绑定到控件属性(字符串)_Wpf_Binding_Inotifypropertychanged - Fatal编程技术网

Wpf 将元素绑定到控件属性(字符串)

Wpf 将元素绑定到控件属性(字符串),wpf,binding,inotifypropertychanged,Wpf,Binding,Inotifypropertychanged,所以,我找到了一种将标签绑定到当前控件的属性的方法 我给它起了个名字: <UserControl x:Class="WpfGridtest.GridControl" x:Name="GridControlControl1"> 然后绑定到此控件的属性: <Label Content="{Binding ElementName=GridControlControl1, Path=Filter}"></Label> 我可以看到我在该属性中输入的默认值 我

所以,我找到了一种将标签绑定到当前控件的属性的方法

我给它起了个名字:

<UserControl x:Class="WpfGridtest.GridControl" x:Name="GridControlControl1">

然后绑定到此控件的属性:

<Label Content="{Binding ElementName=GridControlControl1, Path=Filter}"></Label>

我可以看到我在该属性中输入的默认值

我猜这不起作用,因为我绑定到的字符串属性没有实现INotifyPropertyChanged


我是否应该使用其他类型来代替字符串自动通知我的标签更改,或者我的做法是否错误

INotifyPropertyChanged接口应该由包含属性的类实现,在本例中,由
WpfGridtest.GridControl
实现


此外,如果您想使用您的属性用于UI,请考虑使用<代码>依赖项属性< /代码>作为存储,而不是私有字段。

< P>此外,默认绑定模式也可能是一次,因此您可能需要在<代码> {绑定} /代码> /p>中更改它,并尝试添加NoTIFYONSURCUEPDATATE= true,但也没有变化