The team blog of the Expression Blend and Design products.
Hello! In this article, I’d like to provide you with some information and tips that you’ll find useful when styling a Silverlight 3 ListBox.
Visual states. ValidationStates (Valid, InvalidUnfocused and InvalidFocused). ListBox has the following template parts:
ContentPresenter (ContentPresenter) ContentPresenterBorder (FrameworkElement) DropDownToggle (ToggleButton) Popup (Popup) ScrollViewer (ScrollViewer)
ContentPresenter (ContentPresenter)
ContentPresenterBorder (FrameworkElement)
DropDownToggle (ToggleButton)
Popup (Popup)
ScrollViewer (ScrollViewer)
The following tips will help you out a bit:
Here’s some artwork you might want to try turning into a ListBox:
The XAML that resembles the artwork is:
<Grid x:Name="root" Height="146" Width="146"> <Rectangle Fill="#FF333333" RadiusX="3" RadiusY="3" /> <TextBlock Margin="5,5,0,0" Foreground="White" Text="Lorem"/> <TextBlock Margin="5,26,0,0" Foreground="White" Text="Ipsum"/> <Grid x:Name="verticalscrollbar" Width="17" Height="146" HorizontalAlignment="Right" > <Rectangle x:Name="track" Fill="#FF3D3D3D" StrokeThickness="0" /> <Path x:Name="smalldecrease" Fill="Gray" Stretch="Fill" Width="7" Height="7" Data="M196.89876,311.82065 L204.06047,311.82065 L200.42426,304.87872 z" Margin="0,5,0,0" VerticalAlignment="Top"/> <Rectangle x:Name="thumb" Fill="Gray" RadiusX="3" RadiusY="3" Height="61" Width="7" Margin="0,24,0,0" VerticalAlignment="Top"/> <Path x:Name="smallincrease" Fill="Gray" Stretch="Fill" Width="7" Height="7" Data="M196.89876,304.83246 L200.52762,312.02783 L204.07646,304.83078 z" Margin="0,0,0,5" VerticalAlignment="Bottom" /> </Grid> </Grid>
To create a real ListBox out of your artwork, perform the following steps:
After you have done this, you should now have a working ListBox!
- Steve
Great post Steve
I have a question. I only need to style the listbox to get rounded corners on it. However the scrollviewer is stubborn and interferes with the other corner radius' i define for the borders inside the ListBox template making a hash of things.
So, from a clean original template of a ListBox, is there a simple way to give it rounded corners?