I have a very basic question about binding between controls.
I have a class that has bunch of fields, lets call it “Style”.
One of the field is called “Images” with only getter and no setter.
Then i have another class “StyleImages” that is called with constructor “new StyleImages (Style)” in getter on class “Style”. Meaning that every time i call Images on Style i always get fresh Images created for current style.
In WPF i created a window. In XAML i have two controls.
1) Image control.
2) PropertyGrid control (from WF).
In code behind i create new instance of Style. In PropertyGrid i push entire “Style” while in Image control i push Style.Images.Image1
No what i want is when i change any attribute of “Style” in PropertyGrid i want that the Image control is refreshed.
What is the proper way to achieve this? If necessary i will paste some code also.
You need to notify that the property has changed.
Consider implementing INotifyPropertyChanged and INotifyPropertyChanging.
Every time any other property changes, call OnPropertyChanged(“ImageControl”). This way WFP framework will know the property changed and will act accordingly.
Also, make sure the Binding mode is correctly set, for debug purposes set it=TwoWay.