This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, i am using the grid for objects of the same datatype. when i switch from one selected object to another i need the grid to remember which properties from the first object the user already has expanded, so that i can expand them for the second object as well. any hints? thanks a lot, r.
|
|
|
There's no built-in support for this. The best you can do is to iterate over the BindingView collection, get the TreeViewItem for each row and check its IsExpanded property. Something like this (error checking omitted, and not tested!): var expansionStatus = new Dictionary<string, bool>(); Note this only looks at top-level properties: if you need to go into nested properties you'll need to recurse down the tree. |
|
|
Hi I have a question related to the issue mentioned in this post. I use the following markup in the propertygrid in order to categorize the properties: Grouping='{x:Static ms:PropertyGrouping.ByCategory}' How can I make the property grid remember if the category was expanded or not if I set SelectedObject to another instance?
Kindly regards
|
|
|
In the default themes, group expansion is held purely in the view, so in order to do this you will need to either retemplate the grid or delve pretty intimately into its visual tree. Here's how to extract the info from the visual tree: TreeListView tlv = (TreeListView)(PropertyGrid1.Template.FindName("PART_Grid", PropertyGrid1)); // Helper method for getting top-level children even if they're not immediate Restoring the expansion state is the converse, with the wrinkle that you will probably need to defer the code until the WPF binding cycle has had time to run (because otherwise the visual tree won't be ready). To do this, use Dispatcher.BeginInvoke with a priority of ApplicationIdle. Note also you will need to look up the remembered state based on a token such as a string, because the GroupItem instances will be recreated each time. |
|
|
Thank you for your help :) This is exactly what I need. John R |
|