Well I'm designing a Custom WPF control - fore the sake of learning - that display logs message in a similar way Visual Studio does. I want开发者_JAVA百科 to allow the user add messages by adding message istances to an Items
collection, or by binding to an ItemSource
. I think this is a well established pattern in many wpf controls, but I have no Idea on how achieve it. I know I can obtain the same result by adding a listview as a part of my control, but the project goal is learning, so I prefer avoid that solution. Any idea ?
Have a read around the ItemsControl
, your custom control can inherit from an ItemsControl
, or a derivative of it. If you create an ObservableCollection
containing your items and bind that to your ItemsSource
, then your list will be automatically updated. You can style the ItemTemplate
and Template
to give the list a different look and feel.
There's loads of info here
精彩评论