Good day.
I am trying to display data from System.Data.DataTable in Microsoft.Toolkit.Uwp.UI.Controls.DataGrid. I bind the component to the table through the CollectionViewSource.
Under UWP, cannot work with Windows.UI.Xaml.Data.CollectionViewSource object.
Unable to assign CollectionViewSource.Source by System.Data.DataTable object.
When trying to assign, an error is thrown:
System.ArgumentException: 'Value does not fall within the expected range.'
Here's some sample code:
private void Button_Click(object sender, RoutedEventArgs e)
{
System.Data.DataSet northwindDataSet = new DataSet();
northwindDataSet.ReadXml(@"NorthwindDataSet.Xml");
System.Data.DataTable dataTable = northwindDataSet.Tables["Customers2"];
Windows.UI.Xaml.Data.CollectionViewSource viewSource = new CollectionViewSource();
viewSource.Source = dataTable;
}
Under WPF, similar code works correctly, without errors.