In Expression Blend you can create a font-size of say 18 and then create a "font-size resource".
Coming at this from HTML/CSS, I cannot think of when I would want to make a style for a "font-size" and one for a "font-style" and one for a "font-weight". Instead I want to make a font called "CompanyHeader" and have 10 different attributes set in it, e.g. font-weight, font-style, font-size, color,etc.
Why is this different in Expression Blend, XAML, what is the sense of making a style/resource for each attribute?
this graphic shows how you can click on a little button on each attribute to change it into a resource: alt text http://tanguay.info/web/external/blendStyles.png
I have no experience with Blend, but styles in XAML can include more than one attribute, more then that, since unlike css you can only apply one style to an element you can't combine multiple one-attribute styles.
Here is an example for a style that set multiple properties:
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Page.Resources>
<Style x:Key="MyStyle" TargetType="{x:Type Label}">
<Setter Property="Width" Value="125"/>
<Setter Property="Height" Value="25"/>
<Setter Property="Background" Value="Red"/>
</Style>
</Page.Resources>
<Label Style="{StaticResource MyStyle}"/>
</Page>
Note that if I wanted to break the style into 3 smaller styles each setting one property I couldn't use them because the Label's Style property can only accept one style.
I think they likely allow for the creation of single resources for FontFamily, FontWeight, etc. to allow them to be used across many styles in the application. By placing a single property in a resource you can effect all styles using that resource at once. If you weren't using a resource but were attempting to use a consistent FontFamily across your whole application (or a portion of it) then you had to go through each style one at a time in order to update it.
In order to make a style with multiple properties in blend you can do the following:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With