Tech Off Thread

4 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Creating a style in Blend

Back to Forum: Tech Off
  • User profile image

    Expression Blend is a bit confusing sometimes isn't it?


    I know one of the brilliant things you can do in Silverlight/WPF is totally remake the look of a control by editing its control template. But you can also drag a plain old button onto the canvas and change some properties, say the border brush and the font.  You can also make a style that just sets these basic properties without messing with the control template, as per this example from this Silverlight site.


    <Style TargetType="Button">
      <Setter Property="BorderThickness" Value="5" />
      <Setter Property="Foreground" Value="Blue" />
      <Setter Property="BorderBrush">
          <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
            <GradientStop Color="Yellow" Offset="0.0" />
            <GradientStop Color="Red" Offset="0.25" />
            <GradientStop Color="Blue" Offset="0.75" />
            <GradientStop Color="LimeGreen" Offset="1.0" />


    What I can't work out is how to create a style like this in Blend without hand-editing XAML. Is there any way?


    The help files for Expression Blend advises that you style controls by selecting your control and using the menu option "Edit Template->Edit Copy", but that just copies the default control template and default property values for the control type.


  • User profile image

    I've looked all over and apparently there is no way to do this incredible simple thing in Blend. In fact it doesn't have much support for working with styles at all, four versions in, which is weird given how powerful styles are in WPF/Silverlight. While there is support for moving styles (and other resources) between resource dictionaries, there's nowhere that tells you when a style is based on another style or to set that up without editing XAML.


    The good news is, Blend as a plugin API so I can write a plugin to cover some of these oversights. That bad news is they haven't documented it at all.

  • User profile image

    It is possible. Just set select the Style from the resources panel to edit it, and then in the Triggers panel select "Default". Then, change any values in the properties panel, and the new values will be created as Setters inside the Style, just like you want.

    Hope this helps

  • User profile image
    Maddus Mattus


    1. Create a new resource dictionary (if you want to work with styles)
    2. Drag a control to somesort of work area
    3. Style the control the way you want
    4. Right click of the control and select Edit Template
    5. Select create as a copy and select the dictionairy

    There you have your style, without XAML typing Smiley



Conversation locked

This conversation has been locked by the site admins. No new comments can be made.