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'm not sure which is the best way to do this, but basically - I always want my property grid to be grouped by category. Currently, I just use this code: Dim grouper As New PropertyGroupDescription("Node", New Mindscape.WpfPropertyGrid.NodeToCategoryConverter())MyPropertyGrid.BindingView.DefaultView.GroupDescriptions.Add(grouper) But is it possible to define this in xaml? Sorry if I have missed the glaringly obvious! Regards, Justin Rafferty. |
|
|
You haven't missed anything -- we don't currently have a way to do this in XAML. We will add this to the wishlist. (We would like any XAML interface to sorting and grouping to be reasonably flexible, not hardwired to CategoryAttribute, which makes it a bit less trivial to implement.) As a workaround, you could of course create a derived class and add the code to that -- not very pretty though, I admit. |
|
|
I've just committed support for sorting and grouping in XAML, and it will be in the next nightly build (available from about 1800 GMT). See the new Sorting and Grouping properties. The PropertySorting and PropertyGrouping static classes contain standard strategies (grouping by category and alphabetical sorting), which you can reference as follows: <ms:PropertyGrid Grouping="{x:Static ms:PropertyGrouping.ByCategory}" /> (etc.) You can of course define your own custom sorting and grouping strategies and reference them from your XAML. Note that Sorting is an IComparer not a SortDescription. This gives additional flexibility at the expense of some additional complexity in specifying the sort. Sorting and Grouping are dependency properties so you can use them in styles, for example to specify by-category grouping as part of a standard style. There are various rules about how the Sorting and Grouping properties interact with the sorting and grouping settings on BindingView.DefaultView, but the simplest rule to follow is "don't mix them" -- use either the Sorting property or the SortDescriptions collection, but not both (and similarly for Grouping/GroupDescriptions). Finally, Grouping supports only one level of grouping, as we believe this is the common case for property grid scenarios, and that subgrouping is potentially visually confusing without some major retemplating. We are open to feedback if you feel that subgrouping from XAML is an important feature. (You can still subgroup from code using BindingView.DefaultView.GroupDescriptions; the limitation applies only to the PropertyGrid.Grouping shortcut.) |
|