开发者

Binding an Element to a Control Property (string)

开发者 https://www.devze.com 2023-01-01 16:26 出处:网络
so, i\'ve found a way to bind a label to a property on current Control i give it a name: <UserControl x:Class=\"WpfGridtest.GridControl\" x:Name=\"GridControlControl1\">

so, i've found a way to bind a label to a property on current Control

i give it a name:

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

and than bind to property of this control:

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

I can see the default value i put in that property.

I am guessing that this isn't working because i am binding to String property which doesn't implement INotifyPropertyChanged??

is there some other type i should be using for this property instead of String auto notify my开发者_开发技巧 label of changes, or am i going about this the wrong way?


The INotifyPropertyChanged interface should be implemented by the class that contains the property - in this case, by your WpfGridtest.GridControl.

Also, if you want to use your properties for UI, consider using a DependencyProperty as a storage instead of a private field.


in addition, it is also likely that the default binding mode is one time, so you may have to change it in your {Binding}

0

精彩评论

暂无评论...
验证码 换一张
取 消