In my C# WPF app, my MainViewModel is having this property:
public object CurrentViewModel
{
get { return m_currentViewModel; }
set
{
m_currentViewModel = value;
OnPropertyChanged("CurrentViewModel");
}
}
Let's say CurrentViewModel returns an instance class VMParent at runtime.
And my VMParent looks like this:
public class VMParent
{
public object BaseViewModel
{
get { return m_baseViewModel; }
set
{
m_baseViewModel = value;
}
}
}
And BaseViewModel property returns an instance of class VMBase at runtime which has certain number of properties.
Now, on click of a button in my MainViewModel.xaml, using reflection, I need to read values of all properties of CurrentViewModel and BaseViewModel. I'm able to do so for CurrentViewModel but not for BaseViewModel.
Any pointers please? Thanks.
Type sourceType = CurrentViewModel.GetType();
PropertyInfo[] sourcePI= sourceType.GetProperties();
Aucun commentaire:
Enregistrer un commentaire