c# - Is it poor practice to call RaisePropertyChanged() for each property in my ViewModel when I need to "refresh" or "update" the view? -


i use reflection grab property names in class of specific type or access level. run these through raisepropertychanged() "update" entire view.

an instance on startup, when program starts , when viewmodel instantiated run ensure view showing correct data model.

is there wrong doing this?

code if guys want it:

    private void initializeviewmodel()     {         foreach (string name in miscmethods.getpropertynames(this))         {             raisepropertychanged(name);         }     }      public static ienumerable<string> getpropertynames(object yourclass)     {         foreach (propertyinfo property in getproperties(yourclass))         {             yield return property.name;         }     }      //uses reflection return properties in class     private static ienumerable<propertyinfo> getproperties(object theobject)     {         return theobject.gettype().getproperties(system.reflection.bindingflags.public | system.reflection.bindingflags.flattenhierarchy | system.reflection.bindingflags.instance);     } 

rise event empty string

raisepropertychanged(""); 

this trigger update all properties.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -