Filter DataGridView items by properties of objects on a List in an item property

37 Views Asked by At

Sorry for the confusing title, will clear it up now. I have a DataGridView (DevExpress) in a XAML MAUI application.

<dxg:DataGridView x:Name="ArticlesGrid"
              ItemsSource="{Binding ArticlesToChooseFrom}"
              FilterString="{Binding GridFilter}"
              IsColumnHeaderVisible="False" SelectionMode="None">
              ...
</dxg:DataGridView>

The items are fed from a ViewModel property:

public ObservableCollection<Article> ArticlesToChooseFrom { get; private set; }

The Article class contains the property:

public List<ArticleAltName> AltNames { get; set; }

The ArticleAltName class contains the property Name.

When the FilterString property of the DataGridView changes it call a method in the ViewModel which changes the filter query string:

GridFilter = $"Contains([ArticleName], '{searchText}')";

How can I filter artiles by their AltNames?

First I thought I could access the child properties with the dot operator:

GridFilter = $"Contains([ArticleName], '{searchText}') or Contains([AltCodes.AltNames.Name], '{searchText}')";

...but the AltNames property contains a List<> instead of a reference to a single object.

0

There are 0 best solutions below