This question is locked. New answers and comments are not allowed.
Hi,
It's very pleasure to meet RadPropertyGrid in Q2.
It would be even better if It provides 'custom sort' by some property say, 'SortDescriptors' or something.
In my scenario, most of properties need to be sorted by its priority as a default.
Imagine, how awkward if the 'Name' property displayed at the bottom of properties for some entity?
Anyway, is there any chance to customize sorting behavior in the release version of Q2 2011?
Oh~ BTW, I made a small customization to do above, using GroupingItemsSourceConverter.
I hope it will be supported by built-in component in Q2'11.
Here's some snippets for others, just in case.
First, I made a derived class from PropertyDefinition for ordering:
Second, a CustomGroupItemsSourceConverter for the 'Grouping Mode':
I only added a line of code which adds SortDescriptor to the QuaryableCollectionView.
Finally, I edited a copy of default Template of RadPropertyGrid, to make the "groupTemplate" uses my CustomGroupingItemsSourceConverter:
As the result, I could see the properties ordered by its priority(order property), as I wished. :D
Regards,
Inseok
It's very pleasure to meet RadPropertyGrid in Q2.
It would be even better if It provides 'custom sort' by some property say, 'SortDescriptors' or something.
In my scenario, most of properties need to be sorted by its priority as a default.
Imagine, how awkward if the 'Name' property displayed at the bottom of properties for some entity?
Anyway, is there any chance to customize sorting behavior in the release version of Q2 2011?
Oh~ BTW, I made a small customization to do above, using GroupingItemsSourceConverter.
I hope it will be supported by built-in component in Q2'11.
Here's some snippets for others, just in case.
First, I made a derived class from PropertyDefinition for ordering:
public class OrderedPropertyDefinition : PropertyDefinition{ #region Order /// <summary> /// Identifies the Order dependency property. /// </summary> public static readonly DependencyProperty OrderProperty = DependencyProperty.Register("Order", typeof(int), typeof(OrderedPropertyDefinition), null); /// <summary> /// Gets or sets the Order possible Value of the int object. /// </summary> public int Order { get { return (int)GetValue(OrderProperty); } set { SetValue(OrderProperty, value); } } #endregion Order}Second, a CustomGroupItemsSourceConverter for the 'Grouping Mode':
public class CustomGroupingItemsSourceConverter : IValueConverter{ public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { QueryableCollectionView qcv = new QueryableCollectionView((IEnumerable)value); GroupDescriptor descriptor = new GroupDescriptor(); descriptor.Member = "GroupName"; qcv.GroupDescriptors.Add(descriptor); // TODO: get SortDescriptors outside of this converter. qcv.SortDescriptors.Add(new SortDescriptor { Member = "Order" }); return qcv.Groups; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); }}Finally, I edited a copy of default Template of RadPropertyGrid, to make the "groupTemplate" uses my CustomGroupingItemsSourceConverter:
<local:CustomGroupingItemsSourceConverter x:Key="CustomGroupingItemsSourceConverter" /><!-- ... --><telerik:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/><!--<telerik:GroupingItemsSourceConverter x:Key="GroupingItemsSourceConverter"/>--> <DataTemplate x:Key="groupTemplate"> <!--<ItemsControl ItemsSource="{Binding ., Converter={StaticResource GroupingItemsSourceConverter}}">--> <ItemsControl ItemsSource="{Binding ., Converter={StaticResource CustomGroupingItemsSourceConverter}}"><!-- ... -->As the result, I could see the properties ordered by its priority(order property), as I wished. :D
Regards,
Inseok