.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,852 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi everyone,
I want to ask how to Bind Picker to IEnumerable<T>. I am using Realm for local database in MAUI android project. Based on Realm's guidance (Data Binding), Realm advises against using ToList(). Therefore, in my ViewModel I design it like this:
C#
public IEnumerable<Employee> Employees { get; }
...
Employees = realm. All<Employee>();
In XAML
<Picker Title="Choose Employee" ItemsSource="{Binding Employees}" ItemDisplayBinding="{Binding Name}" SelectedItem="{Binding SelectedEmployee}" />
By design above, XAML fails to fetch data from IEnumerable<Employee>. Even though the Employees property is filled with data from the results of realm.All<Employee>();
However, if a design like this works.
Its Work
C#
public IEnumerable<Employee> Employees { get; }
...
Employees = new List<Employee>(realm. All<Employee>());
Is this a bug of MAUI or is it my fault?