How Do I Apply a Predefined Style to the Grid?
In addition to its default style, the WPF Property Grid includes three custom styles to give it a more visually distinctive and modern appearance.
To apply a predefined style to the grid, you must:
- Add the appropriate ResourceDictionary to the window or application resources.
- Set the Style property of the grid to the style identified by the predefined key.
Adding the Predefined Style’s ResourceDictionary
To merge the predefined style’s ResourceDictionary into the window resources:
CopyMerging the predefined ResourceDictionary
<Window.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ms:Alloy/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Window.Resources>
You can also merge the dictionary into the application resources, and/or add the dictionary from code-behind.
If you want to use multiple styles (for example to support user selection), you can instead use the combined PropertyGridStyles ResourceDictionary.
Setting the Style Property of the Grid
To set the style of the grid:
CopyApplying the predefined style
<ms:PropertyGrid Style='{StaticResource {x:Static ms:Alloy.StyleKey}}'/>
Available Styles
Refer to the Mindscape.WpfPropertyGrid.Styles namespace in the API Reference to see the available styles and the associated dictionaries and keys.