How to get and edit the default Styles of the Silverlight for WP7 Toolkit controls
published on: 3/7/2011 | Views: N/A | Tags: WP7Toolkit Styling
by WindowsPhoneGeek
Recently we received several questions about how to edit the default Style/ControlTemplate of the Silverlight for Windows Phone 7 toolkit controls in Expression Blend. Unfortunately currently the control templates of the toolkit controls are not editable in Blend.
If you try to edit a particular control you will get an empry ControlTemplate without elements.

<phone:PhoneApplicationPage.Resources>
<ControlTemplate x:Key="ListPickerControlTemplate1" TargetType="toolkit:ListPicker"/>
</phone:PhoneApplicationPage.Resources>Getting the default Style/ControlTemplate of the Silverlight for Windows Phone toolkit controls
However you can get the default Style/ControlTemplate directly from the toolkit source code. The steps are as follows:
1.) Download the latest version of the Silverlight for Windows Phone Toolkit
2.)Open the PhoneToolkit solution
3.)Go to the Microsoft.Phone.Controls.Toolkit project and find the Themes folder
4.) Open the Generic.xaml file from the Themes folder

5.) From here you can get all default styles of the Silverlight for Windows Phone toolkit controls.
Using the default Style/ControlTemplate of the Silverlight for Windows Phone toolkit controls
In order to use or modify the style of any particular control just copy its Style from the Generic.xaml and give it some Name/Key. For example:
<Style TargetType="toolkit:ListPicker" x:Name=”MyCustomStyle”>
<Setter Property="Background" Value="{StaticResource PhoneTextBoxBrush}"/>
<Setter Property="Foreground" Value="{StaticResource PhoneTextBoxForegroundBrush}"/>
<Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMediumLarge}"/>
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="Margin" Value="{StaticResource PhoneTouchTargetOverhang}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="toolkit:ListPicker">
...
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<toolkit:ListPicker Style="{StaticResource MyCustomStyle}" />
I hope that this post was helpful.
You can also take a look these articles:
You can also follow us on Twitter @winphonegeek
Comments
Our Top Articles & Free books
- Our FREE e-book: "Windows Phone Toolkit In Depth" 2nd edition
- 400+ Windows Phone Development articles in our Article Index
- 21 WP7 Toolkit in Depth articles covering all controls
- 12 WP7 Coding4Fun Toolkit in Depth articles covering all controls
- Performance Tips when creating WP7 apps
- Creating a WP7 Custom Control in 7 Steps
- WP7 working with VisualStates: How to make a ToggleSwitch from CheckBox
- What makes a WP7 App successful
- Creating theme friendly UI in WP7 using OpacityMask
- Implementing Windows Phone 7 DataTemplateSelector and CustomDataTemplateSelector
- All about Splash Screens in WP7 – Creating animated Splash Screen
- Getting Started with Unit Testing in Silverlight for WP7
- WP7 WatermarkedTextBox custom control
Our Top Tips & Samples
- All about WP7 Isolated Storage series
- WP7 Dynamically Generating DataTemplate in code
- 5 tips for a successful WP7 Marketplace submission
- WP7: Navigating to a page in different assembly
- WP7 ContextMenu: answers to popular questions
- WP7 ListBox: answers to popular questions
- WP7 working with Images: Content vs Resource build action
- WP7 Element Binding samples
- WP7 working with XML: reading, filtering and databinding
- Drawing in WP7: #2 Drawing shapes with finger
- WP7 TextBox Light theme problems - the solution
- Changing the WP7 Panorama Background Image dynamically with Animation
