Switching to WPF Property Grid 2.0
Tagged as WPF Property GridWPF Property Grid 2.0 is highly compatible with 1.0, but there are a couple of changes which may affect a small amount of existing code.
First, if you’re using BuiltInEditorStyles to customise the appearance of the built-in editors, you’ll now need to wrap the declarations in a BuiltInEditorStyleCollection. That is, you’ll need to change this:
<ms:PropertyGrid.BuiltInEditorStyles> <!-- ... style declarations ... --> </ms:PropertyGrid.BuiltInEditorStyles>
to this:
<ms:PropertyGrid.BuiltInEditorStyles> <ms:BuiltInEditorStyleCollection> <!-- ... style declarations ... --> </ms:BuiltInEditorStyleCollection> </ms:PropertyGrid.BuiltInEditorStyles>
This has been in nightly builds for a while so you may already have made this change; if so, you won’t need to do anything more.
The reason for this change was to allow the BuiltInEditorStyles property to be set via a style itself. The benefit of this is that if you are styling the grid to give it a custom appearance, you can package up your styling of the built-in editors as part of that style.
Second, we have changed the way that highlighting the tree/list item for the editor cell with focus works. If you have a custom style for your grid rows, you may now find that, when the user clicks into a property to edit it, the corresponding row no longer gets highlighted. The solution for this is to databind the IsSelected property of your item control (ListBoxItem, TreeViewListItem, etc.). You will need to use a MultiBinding similar to the following:
<MultiBinding Converter="{StaticResource AreEqual}"> <MultiBinding.Bindings> <Binding Path="Header" RelativeSource="{RelativeSource Self}" /> <Binding Path="SelectedGridItem" RelativeSource="{RelativeSource AncestorType={x:Type ms:PropertyGrid}}" /> </MultiBinding.Bindings> </MultiBinding>
where AreEqual is an instance of the AreEqualConverter included in the grid assembly.
If you need any further assistance making these changes, let us know in the forums and we’ll be glad to help!
Leave a Reply
Categories
BrainDump (1)
Community Code (4)
Events (16)
F# (14)
General (53)
Lab Samples (2)
LightSpeed (268)
MegaPack (8)
News (71)
NHibernate Designer (26)
Nightly news (53)
Phone Elements (24)
Products (87)
Projects (5)
Screencast (6)
SharePoint (3)
Silverlight (14)
Silverlight Elements (66)
SimpleDB Management Tools (20)
Visual Studio (9)
VS File Explorer (7)
Web Workbench (39)
WPF (44)
WPF Diagrams (57)
WPF Elements (110)
WPF Property Grid (32)



Posted by Ivan Towlson on 17 December 2008 


