I am in the process of getting rid of 3rd party controls. One of the things that is needed is to make a collectionview control that takes a list (just a list) and a grouping property and does the background work to make the grouping list so that I do not have to change much in the existing XAML.
My first attempt was to make an element that was just subclassed from the CollectionView (just a .cs file) -
public partial class MyCollectionView : CollectionView
Now while that works without my changes it has a problem when I want to use a bindableproperty to pass the list to be converted to a grouped list. I can create the BindableProperty and bind the ItemsSource of the CollectionView to the list and it will show the list (not grouped). Now I want to know when the list is sent to my property so I can convert that list to a grouped list. I would use the PropertyChanged event to do that but I can find no way to set an event handler to do this. First off I have created a constructor to add the event handler but when I do I get -
System.Reflection.TargetInvocationException: 'Exception has been thrown by the target of an invocation.'
Now I have about 30 other tests but I am thinking to ask this before I keep going on this. So is this approach (subclassing a control) a valid way to basically add a property that when set will massage the list into a grouped list and set the ItemsSource of the control.