CollectionView as a property

Grids for WPF Forum

Posted 9 years ago by Neil Larson
Version: 15.1.0623
Avatar

I would like to have my collection shown sorted when this class is presented in the PropertyGrid.

As this stands now, I simply get the name of the class "CollectionView" shown in the editor.

 

private ObservableCollection<MultiCueAddLogicalCommand> _Cues = new ObservableCollection<MultiCueAddLogicalCommand>();
[Browsable(false)]
public ObservableCollection<MultiCueAddLogicalCommand> Cues
{
   get { return _Cues; }
   set
   {
      if(_Cues == value)
         return;

      _Cues = value;
      RaisePropertyChanged(() => Cues);
   }
}

private CollectionView _SortedCues;
[DisplayName("Cues")]
[Category("Default")]
[Description("Cues in this MultiCue")]
[TypeConverter(typeof(ExpandableCollectionConverter))]
public CollectionView SortedCues
{
   get { return _SortedCues; }
   set
   {
      if(_SortedCues == value)
        return;

     _SortedCues = value;
     RaisePropertyChanged(() => SortedCues);
   }
}



// constructor

public CreateMultiCueCommand()
{
   SortedCues = (CollectionView)CollectionViewSource.GetDefaultView(Cues);
   SortedCues.SortDescriptions.Add(new SortDescription("TimingOffset", ListSortDirection.Ascending ));
}

 

What do I need to do to have the sorted list shown?

 

Thanks

Comments (1)

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Neil,

I'm sorry but CollectionView isn't supported.  The collection editing features only support objects that implement ICollection, IList, IDictionary, or any of their generic variations.  When we debug through the TypeDescriptorFactory class of ours, the native .NET TypeDescriptor doesn't return that the CollectionView type supports sub-properties (as it does for the collection types mentioned above).  That's why it's not expandable.  Thus, while your Cues property would work, the SortedCues would not.

The only workaround would be to build your own data factory and manually add child property items for each item in that CollectionView-based property.


Actipro Software Support

The latest build of this product (v24.1.3) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.