Binding Map VisualizationLayer ItemsSource to filtered QueryableCollectionView

1 Answer 19 Views
GridView Map
Chandler
Top achievements
Rank 1
Chandler asked on 24 Mar 2025, 07:38 PM

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!

1 Answer, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 26 Mar 2025, 02:59 PM

Hi Chandler,

Yes, using QCV / ListCollection is not directly supported in VisualizationLayer. We have public feature request related logged here.

I have prepared a sample approach which generally wraps the QCV in ObservableCollection and listens for collection changes. Please give it a try and share any feedback.

Regards,
Petar Mladenov
Progress Telerik

Enjoyed our products? Share your experience on G2 and receive a $25 Amazon gift card for a limited time!

Tags
GridView Map
Asked by
Chandler
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Share this question
or