-
Notifications
You must be signed in to change notification settings - Fork 68
Open
Description
Describe the bug
MAUI.DataGrid does not internally handle thread synchronization for updates to its data source. When an item is added to the ObservableCollection from a thread different than the UI thread, the DataGrid does not automatically marshal the change back to the UI thread.
Calling MainThread.BeginInvokeOnMainThread when adding a item to the ItemSource collection solves the problem.
To Reproduce
Steps to reproduce the behavior:
- Define a DataGrid with a
ItemsSourceassociated to anObservableCollection - Add an Item to the
ObservableCollectionfrom another thread, for example withTask.Run(() => itemList.Add(x)); - A COM exception is thrown when
_paginationStepper.IsEnabledis changedMaui.DataGrid/Maui.DataGrid/DataGrid.xaml.cs
Line 1231 in 9b24fb1
_paginationStepper.IsEnabled = value > 1;
Expected behavior
Either no exception, or explicitly state on the documentation that calling BeginInvokeOnMainThread is necessary.
Metadata
Metadata
Assignees
Labels
No labels