Sunday, March 15, 2009 2:37 PM
rudi
Extract Properties To Style
XAML Power Toys
“XAML Power Toys is a Visual Studio 2008 SP1 Multi-AppDomain Add-In that empowers WPF & Silverlight developers while working in the XAML editor. Its Line of Business form generation tools, Grid tools, DataGrid and ListView generation really shorten the XAML page layout time.”
Karl has recently released a new version of XAML Power Toys… My favorite new feature is the “Extract Properties To Style”. Have a look at the following XAML:
<Button
Foreground="Blue"
Background="Yellow"
BorderBrush="OliveDrab"
BorderThickness="5"
Margin="5,5,5,5"
FontFamily="Times New Roman"
FontSize="25"
Width="200"
Height="100">
Click me
</Button>
Highlight the button in Visual Studio and right-click on it. In the context menu, select XAML Power Toys –> Extract Properties To Style
This will launch the Extract Selected Properties To Style dialog box… Here we can give our new style a name (MyFunnyButtonStyle) and we can also select which properties on our button should be placed in the style
Once we clicked on extract, the selected properties will be removed and the following style will be copied into the clipboard
<Style TargetType="{x:Type Button}" x:Key="MyFunnyButtonStyle">
<Setter Property="Foreground" Value="Blue" />
<Setter Property="Background" Value="Yellow" />
<Setter Property="BorderBrush" Value="OliveDrab" />
<Setter Property="BorderThickness" Value="5" />
<Setter Property="Margin" Value="5,5,5,5" />
<Setter Property="FontFamily" Value="Times New Roman" />
<Setter Property="FontSize" Value="25" />
</Style>
Now we can easily re-use this style in all our other buttons!!!
If you found this useful, please 
Filed under: Style, Karl Shifflett, XAML Power Toys