I am going to show you how you can modify the standard ListBox control used in Silverlight 2.0. Many people want to change the default view of this control but they can’t remove the line between the items. If you download the code of the Silverlight control from the official site of Microsoft you will see that after every item there is a line. In this example I will show you how you can remove this line.
Let’s create e new Silverlight 2.0 application and place a ListBox in it.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<ListBox> <ListBox.Items> <ListBoxItem Content="I am the first item in the collection" /> <ListBoxItem Content="I am the second item in the collection" /> </ListBox.Items> </ListBox></pre> <!--more-->In order to change the default look of our items we have to modify the <a href="http://msdn2.microsoft.com/en-us/library/system.windows.controls.itemscontrol.itemcontainerstyle.aspx" target="_blank">ItemContainerStyle</a> property of out ListBox control. <pre lang="xml"><ListBox.ItemContainerStyle> <Style TargetType="ListBoxItem"> <Setter Property="Background" Value="LightBlue" /> <Setter Property="Template"></Setter> </Style> </ListBox.ItemContainerStyle> |