O'Reilly logo

Windows® Phone 8 Unleashed by Daniel Vaughan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using a WrapPanel in Conjunction with a ListBox

WrapPanel is useful to present a list of items using XAML. However, using a WrapPanel to present a bound list of values located in a viewmodel can be best achieved by supplanting the ItemsPanelTemplate of a ListBox with a WrapPanel.

This technique is demonstrated in the downloadable sample code. The WrapPanelViewModel class contains a list of strings, representing the numbers 1 to 5, which we use as the source collection for a ListBox control. The list of strings is generated using the LINQ Range and Select methods. See the following excerpt:

readonly IEnumerable<string> items    = Enumerable.Range(1, 5).Select(x => x.ToString());public IEnumerable<string> Items{     ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required