mercredi 1 février 2017

How to add Properties and Fields Dynamically in C# MVVM

In a WPF MVVM(Caliburn Micro) application I have a empty ViewModel and a empty View. (The view model doesn't have any properties, and view doesn't have any fields.)

CommonView (CommonView.cs)

CommonViewModel (CommonView.xaml - UserControl)

There is a need to add properties and fields dynamically to the view and ViewmModel.

I have a list of properties in a PropertyInfo object. Based on the PropertyInfo I need to add properties to the ViewModel and fields to View dynamically.

  1. Is It Possible? Can any one explain this with some code sample?
  2. Is it possible to implement INotifyPropertyChange to dynamically added properties?




Aucun commentaire:

Enregistrer un commentaire