views:

26

answers:

1

I've a collection of UserControls which I want to show in a stack panel. I've no control over how and what those user controls contain. I just know that they are some sort of user controls (could be a button, a textblock or any UIElement.) Here is a small example

public class Car : IHasView
{
     public UserControl MyView { get return new MyCarViewThatHasAButton(); }
}

public class Jeep : IHasView
{
    public UserControl MyView { get return new MyJeepViewThatHasATextblock(); }
}

public class MainView : INotifyPropertyChanged{
    private ICollection _myViews;
    public ICollection MyViews {
    get { return _myViews;}
    set{ 
       _myViews = value; 
       NotifyPropertyChanged("MyViews");
    }

...
...
}

In this example, I want to bind to MyViews and show all the views in the collection in a stack panel. How should I go and bind it? I'm new to WPF world.

Thanks.