WPFwiki, wpf, wiki, .net 3.0, windows presentation foundation, FAQ, free resources, solution, development, microsoft Home of the world's largest WPF FAQ
Edit

Category

ItemsControl

Edit

Question

How should I create an ItemsControl (and derived classes) ControlTemplate?

Edit

Answer

The key to building an ItemsControl ControlTemplate (and the derived classes: Selector, ListView, ComboBox, ListBox, etc.) is to make sure to include an ItemsPresenter object somewhere in the ControlTemplate.

An ItemsPresenter will be the placeholder for the panel to display the ItemsControl items.

An alternative is to include directly in the ControlTemplate a Panel with the property IsItemsHost set to true, in which case, that Panel is going to be used to display the ItemsControl's items.

The latter solution however is not as elegant as the first one since it "ignores" the ItemsPanel property of the ItemsControl.

All content is Copyright ©2007 Xceed Software Inc. unless otherwise indicated. See the Terms of Service. Contributors must read and agree to the Contribution Policy. WPFwiki is brought to you by Xceed, makers of the powerful yet free Xceed DataGrid for WPF.