I love the Silverlight Toolkit – it’s a great set of free Silverlight extensions that you can use in your Silverlight project. Source code and unit tests are included: everything you’d want in an extension library. I am playing around with the toolkit and have always been inspired by Bea Stollnitz’s adventures with control templates (especially her Planets Listbox article). One of the great components of the Silverlight Toolkit is a WrapPanel that “Positions child elements in sequential position from left to right, breaking content to the next line at the edge of the containing box.” I wanted to see if I could adapt a Listbox to use the WrapPanel instead of its default vertical StackPanel. It turns out that all I have to do is change the ItemsPanelTemplate to use the WrapPanel:
I have this defined in my App.xaml resources:
x:Class="Demo.App" xmlns:basics="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" xmlns:controls="clr-namespace:Microsoft.Windows.Controls;assembly=Microsoft.Windows.Controls">
<!-- Resources scoped at the Application level should be defined here. -->
And in the Listbox I use the template for the ItemsPanel attribute:
1/23/2009 – Fixed XAML.