How to create a copy of a control’s default style?
Sometimes you need to make some advanced styling changes to a default control, such as a RadioButton, ListBox, DataGrid, Button, etc. However, you may want to keep the majority of the default style the way it is.
In Expression Blend, this is easy to do. If you don’t have Expression Blend and you are developing in WPF, get it immediately. There is a trial version you can test out.
Here is how to get your copy of any control’s default style.
- Open Expression Blend.
- Create a new WPF project. (It is just a temp project.)
- Add the default control to your MainWindow.xaml.
- Right-click on the control and choose Edit Template | Edit a Copy.
- On the Create Style Resource page, click the “New…” button near the bottom right, just to the right of the Resource dictionary option.
- In the New Item window, provide a name that is meaningfule.
- Click OK to create the file and to return the Create Style Resource page.
- Make sure Resource dictionary is selected (it should be) and click OK.
You have now created a copy of the default style of the control. You now have power to manipulate the control in advanced ways.
Important! Be aware that some controls and made up of other controls, and often you have to do this for each control that your control uses. For example, a DataGrid has many different subcomponents such as a ScrollViewer, an ItemsPresenter, Grids, etc…
[…] more on my new WPF Sharp site How to create a copy of a control’s default style? Share this:ShareFacebookStumbleUponDiggEmailReddit Category: C# (C-Sharp), Expression Blend, […]