How to use global style in Windows Phone 7?
I want to use global style in WP7, for example:
<Style TargetType="Button"> //some code here </Style> The problem is that this code does not work in WP7.
I know how to add x: The key to the style and after that how to refer to it as a StaticResource, but that's not my business. I want a global style.
If you understood correctly that you want to use implicit styles in WP7.
If so, keep in mind that: Implicit styles are a feature of Silverlight 4 (and WPF): Windows Phone 7 is based on Silverlight 3+ (with some Silverlight 4 features added). Since theres no Implicit Styles in Silverlight 3, this means that using them in Windows Phone 7 is also not.
So, if you want to implement some kind of global style in WP7, I would suggest you try the approach with StaticResource as Matt Lacey .
If I create a general view of the application (global), for example:
<Application.Resources> <Style x:Key="MyTextNormalStyle" TargetType="TextBlock"> <Setter Property="Foreground" Value="White" /> <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeNormal}" /> <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyNormal}" /> </Style> </Application.Resources> Then I can refer to it as follows:
<TextBlock Text="some text" Style="{StaticResource MyTextNormalStyle}" /> WP7 Mango supports the implicit styling feature. In mango, MS upgraded silvelight 3 to silverlight 4. So it works great
try this link: http://www.windowsphonegeek.com/articles/Windows-Phone-7-Mango-Implicit-Styles
If you want all of your buttons to use the same style, you need to create a base button class that implements the style and then inherits all of your buttons.
You can do this using a custom control or a custom control. User management is probably easier.