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've seen a few posts on sorting and categorizing and they were helpful (I am using the NodeToCategoryConverter method). Problem is, the categories themselves are not sorted; I can't tell what order they will appear in. Can I get the rows grouped by category AND the categories sorted (alphabetically, or better yet, sorted in a custom way) Thanks. |
|
|
As far as I know, WPF has no tremendously elegant method for controlling the order of groups [categories] in list controls (such as the WPF Property Grid). So far the only way I have found of doing this is to set up the category names explicitly, in the order you want them: GroupDescription
groupDescription = /* whatever */; Is this a viable option for you or do you need a more dynamic runtime method of arranging the categories (e.g. using a comparison callback)? If so, let me know and I will see if I can turn up anything further. |
|
|
Hi Ivan, This is a viable option for me. I have a small prop page with properties that use the [Category] attribute. I tried doing what you suggested and it lists the categories that I added as separate empty categories with my original categories disconnected. See file attachment. Peace Er |
|
|
It looks like whatever is mapping rows to categories is getting it wrong: it is returning the PropertyGridRow object as the group name, rather than the value of the CategoryAttribute associated with that PropertyGridRow. This mapping is the job of a GroupDescription, usually in conjunction with an IValueConverter, so I'm guessing something is amiss with your GroupDescription or IValueConverter. You should have something in your XAML along the lines of <ms:PropertyGrid Grouping="..." /> or in your code-behind along the lines of: grid.BindingView.DefaultView.GroupDescriptions.Add(...) (The former just maps to the latter behind the scenes.) I'm guessing you probably have the code-behind version because you are setting up the group names in code before adding the grouping. In this case the ... should be something like new PropertyGroupDescription("Node", new NodeToCategoryConverter()). ("Node" extracts the grid node from the grid row, and NodeToCategoryConverter extracts the value of the Category attribute.) Is that what you have? If not, what do you have? Hope this makes sense -- let me know if you need further info. |
|