Hello,
In our app we are using filtering through a RadGridView bound to a QueryableCollectionView that wraps an ObservableCollection. Now I'm trying to use that filtered QueryableCollectionView as the ItemSource for a VisualizationLayer in a RadMap so that the filter on the grid also applies to items shown on the map, but the bind fails with the following error: "System.ArgumentException: 'Telerik.Windows.Data.QueryableCollectionView' is not a valid value for property 'Source'."
I've attached a quick project replicating the issue with the relevant code in MainWindow.xaml:
<!-- Doesn't work -->
<telerik:VisualizationLayer ItemsSource="{Binding ItemViewModelsView }" ItemSelectionMode="None">
<telerik:VisualizationLayer.ItemTemplate>
<DataTemplate DataType="{x:Type local:ItemViewModel}">
<Ellipse Fill="Blue" Width="12" Height="12" telerik:MapLayer.Location="{Binding Location}"/>
</DataTemplate>
</telerik:VisualizationLayer.ItemTemplate>
</telerik:VisualizationLayer>
<!-- Also doesn't work pulling directly from the GridView -->
<telerik:VisualizationLayer ItemsSource="{Binding Items, ElementName=GridView }" ItemSelectionMode="None">
<telerik:VisualizationLayer.ItemTemplate>
<DataTemplate DataType="{x:Type local:ItemViewModel}">
<Ellipse Fill="Blue" Width="12" Height="12" telerik:MapLayer.Location="{Binding Location}"/>
</DataTemplate>
</telerik:VisualizationLayer.ItemTemplate>
</telerik:VisualizationLayer>
<!-- Works but isn't filtered -->
<telerik:VisualizationLayer ItemsSource="{Binding ItemViewModels }" ItemSelectionMode="None">
<telerik:VisualizationLayer.ItemTemplate>
<DataTemplate DataType="{x:Type local:ItemViewModel}">
<Ellipse Fill="Blue" Width="12" Height="12" telerik:MapLayer.Location="{Binding Location}"/>
</DataTemplate>
</telerik:VisualizationLayer.ItemTemplate>
</telerik:VisualizationLayer>
and the ViewModel:
public partial class MainWindowViewModel : ObservableObject
{
[ObservableProperty] private ObservableCollection<ItemViewModel> _itemViewModels;
public QueryableCollectionView ItemViewModelsView { get; private set; }
//...
}
It appears to me that the issue is because QueryableCollectionView is both an IEnumerable and a ICollectionView so when it tries to assign it to the MapItemsSource the CollectionViewSource.IsSourceValid() that's called during that assignment is returning false because it is an ICollectionView.
Is there a known workaround for this or suggested alternative to get the expected functionality?
Thanks!