c# - Binding error when binding CollectionViewSource to custom ItemsSource -
i have written control having issues binding collectionviewsource itemssource property. if bind observablecollection itemssource property works expected. collectionviewsource bound following binding error in output.
error: converter failed convert value of type 'windows.ui.xaml.data.icollectionview' type 'ibindableiterable'; bindingexpression: path='jobview.view' dataitem='app.viewmodel.mainviewmodel'; target element myspecialcontrol.myspecialcontrol' (name='null'); target property 'itemssource' (type 'ibindableiterable').
public sealed class myspecialcontrol: control { public ienumerable itemssource { { return (ienumerable)getvalue(itemssourceproperty); } set { setvalue(itemssourceproperty, value); } } public static readonly dependencyproperty itemssourceproperty = dependencyproperty.register("itemssource", typeof(ienumerable), typeof(myspecialcontrol), new propertymetadata((ienumerable)null, onitemsourcepropertychanged)); private static void onitemsourcepropertychanged(dependencyobject d, dependencypropertychangedeventargs e) { ((myspecialcontrol)sender).onitemsourcepropertychanged((ienumerable) eventagrs.oldvalue, (ienumerable)eventagrs.newvalue); } private void onitemsourcepropertychanged(ienumerable oldvalue, ienumerable newvalue) { inotifycollectionchanged oldcollectionchanged = oldvalue inotifycollectionchanged; if (oldcollectionchanged != null) oldcollectionchanged.collectionchanged -= itemsource_collectionchanged; inotifycollectionchanged newcollectionchanged = newvalue inotifycollectionchanged; if (newcollectionchanged != null) newcollectionchanged.collectionchanged += itemsource_collectionchanged; } private void itemsource_collectionchanged(object sender, notifycollectionchangedeventargs e) { ... } }
in xaml have bound collectionviewsource.view
any ideas how change itemssource accept observablecollection collectionviewsource.view ?
thanks
Comments
Post a Comment