开发者

HeaderedContentControl ItemsSource

Why there is no HeaderedContentControl ItemsSource property?

How then can I databind to a li开发者_运维问答st of objects to be represented by HeaderedContentControl?

Thanks John


Because ItemsSource is all about multiple pieces of content, and HeaderedContentControl has one piece of content. Put another way, HeaderedContentControl's job is to present a single object, so it doesn't need a property whose job is to feed it multiple pieces of content.

Use HeaderedItemsControl instead, or (depending on your requirements) an ItemsControl where the DataTemplate is a HeaderedContentControl. (Though in the latter case you might as well just use a Panel and multiple elements within the panel -- the HCC isn't really buying you anything.) HIC's job is to present multiple items under a single header, and it's pretty flexible. For example, the framework uses HIC as the base class for both TreeViewItem (whose "header" is the item at hand, and whose "items" are the children of that item) and MenuItem (whose "header" is the menu item, and whose "items" are any sub-menu-items, for example in a drop-down or pop-out menu).


There's no ItemsSource property, since it can have only a single child (or two children if you count Header in), just like the class it inherits from - ContentControl. Use Content property instead.

You can find more about it on MSDN.

If you want to display list of objects within HeaderedContentControl, then just add ListBox as its Content and fill ListBox with objects.


Maybe you need a HeaderedItemsControl.

You can find a sample here.


You should be able to bind the collection to the Content property.

HeaderedContentControl by name itself is a collection of ContentControl each with Header.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜