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
|
I house a PropertyGrid in a separate panel in my app with it's SelectedObject bound to the CurrentSelections property of a SelectionTracker class. When users click on various other elements of the UI, the SelectionTracker sets the CurrentSelections property to that item. The PropertyGrid responds by displaying the properties and their values for the currently selected element. That works well, except that every time the user selects a new element, the PropertyGrid displays all the nodes collapsed. The user has to manually expand them to see (or change) the properties in them. This is annoying, to say the least, especially when the user expands several nodes, clicks on some other element, and then clicks back to the first element only to find all the nodes collapsed again. I'd prefer to have all the nodes expanded every time the user clicks on an item. But, as several of your posts indicate, this is not an easy thing to do. I read through and tried implementing the approach outlined in "Expanding / Collapsing nodes" (http://www.mindscapehq.com/forums/thread/2567), removing the criteria parameter as suggested in "WPF PropertyGrid : Expand all nodes" (http://www.mindscapehq.com/forums/thread/4679). I tried calling the code from a handler for the Loaded event, but that is only called once -- when the PropertyGrid is loaded, which in my app happens when the application is started at which time there is nothing selected and therefore no nodes to expand. Is there some other event I can use that is raised each time the SelectedObject changes -- one that would allow me to get access to the PropertyGrid so I could expand the nodes using the suggested code? Thanks in advance, BillBR |
|
|
Hello BillBR In the next nightly build, the PropertyGrid will have an ExpanderMode property. If you set this to ExpanderMode.Expanded, all the items will be initially expanded. It's best not to set this property on huge model structures as having all items expanded will affect the performance. Also, avoid setting this property on looping model structures. I have added a check to avoid infinite loops just in case though. You may also/alternatively be interested in the IsExpandedStatePersistent property. If you set this to true, the PropertyGrid will save the expanded/collapsed state of items that the user manually changes. Then when you switch between selected objects, the PropertyGrid will retain these user settings. Jason Fauchelle |
|
|
Jason, you guys rock! This feature saves us from writing a great deal of messy code. And it works great -- even when adding items to collections. BTW, you may want to add an entry to the two postings I referenced in my original question to let them know about this new capability. That way anyone coming across them during a search will have the answer they're looking for. Thanks so much, BillBR |
|