The VisualizationLayer will support using the collection views such as System.Windows.Data.ListCollectionView as its items source.
Hi,
I will post an idea for workaround discussed in the conversations with Chandler.
Bind the ItemsSource of the VisualizationLayer to ObservableCollection which simply wraps the CollectionView. This can be implemented with IValueConverter like so:
public class QcvToObservableCollectionConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is QueryableCollectionView queryableCollectionView)
{
var observableCollection = new ObservableCollection<object>();
foreach (var item in queryableCollectionView)
{
observableCollection.Add(item);
}
queryableCollectionView.CollectionChanged += (sender, e) =>
{
if (e.Action == NotifyCollectionChangedAction.Add)
{
foreach (var newItem in e.NewItems)
{
observableCollection.Add(newItem);
}
}
else if (e.Action == NotifyCollectionChangedAction.Remove)
{
foreach (var oldItem in e.OldItems)
{
observableCollection.Remove(oldItem);
}
}
else if (e.Action == NotifyCollectionChangedAction.Reset)
{
observableCollection.Clear();
foreach (var item in queryableCollectionView)
{
observableCollection.Add(item);
}
}
};
return observableCollection;
}
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
Regards,
Petar Mladenov
Progress Telerik
Enjoyed our products? Share your experience on G2 and receive a $25 Amazon gift card for a limited time!
I've run into a similar issue trying to bind a Telerik QueryableCollectionView to a VisualizationLayer's ItemsSource and found that it doesn't support even plain CollectionViews which I would expect to work for anything that allows binding to collections.
I've made a forum post detailing my situation here: https://www.telerik.com/forums/binding-map-visualizationlayer-itemssource-to-filtered-queryablecollectionview