Reputation: 1950
I'm getting started with WP7 / silverlight and I'm realizing that I want to have certain styles defined rather than having to specify colors/fonts, etc on every single item.
Can someone point me to a good resource that explains how this works? Is there some equivalent to say.. css?.. that would let me define styles? I'm just not positive how this model works.
Upvotes: 3
Views: 855
Reputation: 54600
I think the basic way this works is in your <Application>
element, you can define styles as resources:
<Application.Resources>
<Style x:Name="MyStyledText" TargetType="TextBlock">
<Setter Property="FontFamily" Value="Segoe WP"/>
<Setter Property="FontSize" Value="24"/>
<Setter Property="Foreground" Value="#123456"/>
</Style>
...
And then when you want to use it, you can just refer to it as a static resource:
<TextBlock Style="{StaticResource MyStyledText}" ... />
You can also specify resources per-page if you don't want them to be global:
<phone:PhoneApplicationPage.Resources>
<Style>
...
</Style>
...
There are some other subtleties and such that all of the other links in this thread no doubt go into, but if you just want something to do the basic styling, this seems to be a reasonable pattern.
Upvotes: 2
Reputation: 16826
Also, remember that Windows Phone 7 has a set of pre-defined styles that you can use in your application.
For a complete list, read this article.
Upvotes: 2
Reputation: 2730
Check these:
http://expression.microsoft.com/en-us/cc136522.aspx
Windows Phone 7 Design Templates
Build beautiful apps with Windows Phone 7 design guidance
http://www.microsoft.com/design/toolbox/
Hope this will help you.
Upvotes: 1
Reputation: 16319
For general information about how the styles and templates approach works, check out Customizing the Appearance of an Existing Control by Using a ControlTemplate article on MSDN.
For customizing framework controls, this MSDN Reference details the styles and templates for various Silverlight controls, which helps you to understand the structure of these controls.
You can find the default styles and templates for the framework controls in the C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v7.0\Design folder.
Upvotes: 4
Reputation: 5077
http://wp7designtemplates.codeplex.com/
With these templates you can easily create common Windows Phone UI layouts by simply copying and pasting the desired page.
Upvotes: 2