c# - What triggers change notification in DependencyProperties? -


I am looking for a database in C # and want to understand what types of changes in a property (supported by dependence assets) actually trigger the update notification to trigger targets.

I use simple setup of classes where I can test change in nested properties (sub-properties):

  // person name With a public class person {public string name {get; Set; }} // Class is giving dependency property as a public class to the best friend Friends: dependencyobject {public stable dependencyprofitprofitproperty = dependencyability Registration ("BestFreend", Typef (Person), Typef (Friend)); Get Public Insurance BestFriend {Return (Person). Gate value (bestfried property); } Set {this.SetValue (BestFriendProperty, value); }}}   

Now I attach the property of any other class to BestFriendProperty (as a source). I expected that the update notifications only work through this binding if I use the set of bestfriends:

  myBoundFriends.BestFriend = new person (); // myBoundFriends is a kind of friend   

But I found that even a direct change of property named (nested) triggers information and synchronization for bound target actions:

  myBoundFriends.BestFriend.Name = "Otto"; // Why does this trigger update?   

Database seems to be some kind of mysterious for me. In fact, I think that only freezing objects (widely used in the WPF) are able to trigger the update, when any of its sub-properties changes ?!


Edit: Simple converter to the medium-binding person:

  Public class Individual Recovery Converter: IvCuentor {public object convert (type object type, type type, Object parameter, system globalization. Culture info culture) {purse p = (person) value; New Person (Return String.Copy (P. Names)); } Public Object Convertback (Type Object Value, Type Type, Object Parameter, System. Globalization. Culture Information Culture) {purse P = (Person) Value; New Person (Return String.Copy (P. Names)); }}   

Note that by copying the converter name string the person creates a deep copy of the object. I think that this solution can be a relevant point.

This is your problem, your data does not have modal implement the INotifyPropertyChanged interface.

  public class person {public string name {get; Set; }}   

Change it to

  the person in the public category: INotifyPropertyChanged {Private string name; Public string name {get {return name; } Set {if (value == name) return; Name = value; OnPropertyChanged (); }} Private Event PropertyChangedEventHandler PropertyChanged; [NotifyPropertyChangedInvocator] // Comment this feature if you have R # protected virtual zeroes not open ([CallerMemberName] string propertyName = null) {PropertyChangedEventHandler Handler = PropertyChanged; If (handler! = Null) handler (this, new property changed event event (property name)); }}   

This will prompt GUI to radar things related to the property of your name, when it will change to your code. Alternatively, you can use the DO as a base class and you can make the name property DP, but it is just overkill. I usually have a base class that implements the interface for both my view-models and datamodel.

And of course, I'm a addictive addict;)

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -