ItemsControl Customization
One of the cool things about ItemsControls is that you get to separate the data binding and item control logic from the layout logic by specifying the Panel that you want to lay items out.
There are two ways of specifying a Panel for an ItemsControl. One of them is to use the ItemsPanel property, which allows you to specify an ItemsPanelTemplate that is used to instantiate the Panel of choice.
The other method is to have a Panel in the Template for the ItemsControl, and set IsItemsHost to true. This will tell the ItemsControl that this Panel is the one who is hosting the Items for the ItemsControl and laying them out.
The reason why this is so cool is because it allows the application developer to separate out many aspects of a control into separate reusable pieces, each of which is not too tightly bound to the other. For example, the WPF ListBox does not have to stack items vertically, or have every item the same size. It can use any Panel to lay out the items, because what makes it a ListBox does not involve the item layout. Try setting the Panel of a ListBox to a WrapPanel (or some other panel that lays out items automatically) to see this in action.
Comments
- Anonymous
September 17, 2006
That is nice, but I had PAIN trying to make (in XAML) the Items inside an ItemsControl (like menuItem or listbox) show up in more then one Panel (or having mutiple ItemsPresenter in the templ.) or even dynamicly switching between two Panels (with IsItemsHost = true/false trigger setting)...Neither binding nor complicated ControlTemplates with triggers worked :( :( :(
If have you any suggestions please talk about it or poit me in the right direction! I failded to find anything...
10x
MihailNajdenov
---
Sorry for my English! - Anonymous
January 10, 2007
The comment has been removed - Anonymous
February 27, 2007
Hi.Not sure if its the right place for this - but it is about UI.I just acquired a WM5 device (the Treo 750) and the problem is that I can't read the default fonts (since I use reading glasses ). Although I have WM set up to max font sizes (with ClearType on), when I type in a name and it gives me a choice of phone numbers - I can't read those options due to the font sizesanyway to customize this???ThanksDineshPS: Pls reply to d86b@yahoo.com