Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
60
xamPropertyGrid and 'interface type'
posted

Hello friend,

Hope someone can help me on this:

I am facing with a issue when binding propertyGrid with 'interface type' in ViewModel class:

public class MainViewModel
{

     public IParent Parent

     {

          get;

          set;  

     }

}

public Parent : IParent

{

     public Parent(string name, IChild child)

     {

          this.ParentName = name;

          this.Child= child;

     }

     string ParentName {get;set;}

     IChild Child {get;set;}

}

public class Child : IChild

{

     public string ChildName {get;set;}

     public int Age {get;set;}

}

public interface IParent

{

     string ParentName {get;set;}

     IChild Child {get;set;}

}

public interface IChild

{

     string ChildName {get;set;}

     int Age {get;set;}

}

 and when bind it to PropertyGrid 

{

     MainViewModel vm = new  MainViewModel();

     vm.Parent = new Parent() { ParentName = "ParentName", Child = new Child(){ChildName = "ChildName ", Age = 3} };

     propGrid1.SelectedObject = vm;

}

then I can expand Parent but I can NOT expand 'Child'' properties.

I am confused what wrong I am going now? Could someone please give me an explaination.

Thank you,

BR

Parents Reply Children