I have a DataTable. I want to print it to the interface Maui. How can I do that?
In WPF I did it like this on C#:
gridPrinted.ItemsSource = myclass.GetDataTable().AsDataView();
WPF XAML:
<DataGrid x:Name="gridPrinted" Grid.Row="1" LoadingRow="gridPrinted_LoadingRow" CanUserAddRows="False"/>
In Maui, I have been trying to use CollectionView like this:
C# code:
DataView dat = myclass.GetDataTable().AsDataView();
XAML code:
<CollectionView ItemsSource="{Binding dat}">
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid Padding="10">
<Label Grid.Column="1"
Text="{Binding label}"
FontAttributes="Bold" />
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
However nothing happens. No table is generated, but also no errors, no exceptions, nothing. How can I print that table?
We couldn't see the other code of your app, but you can try to check the following aspects:
1.DataView dat = myclass.GetDataTable().AsDataView();
Here, the returned type of myclass.GetDataTable().AsDataView()
should be a list,for example:
public ObservableCollection<YourItem> items;
or
System.Collections.Generic.IList<YourItem> items;
2.make sure set the BindingContext
for your page;
3.make sure there is a returned value for the ItemsSource
of your CollectionView.
myclass.GetDataTable().AsDataView();