I want to create a Datagrid to load a database query, using this example https://github.com/RSuter/MyToolkit/wiki/DataGrid but I don't understand exactly how to load the list.
but i found this code
<controls: DataGrid x:Name = "DataGrid" ItemsSource = "{Binding Plactas}" SelectedItem = "{Binding PlactaSelected, Mode = TwoWay}" DefaultOrderIndex = "0" SelectionMode = "Extended">
In the ViewModel I already have the list called Plactas
and it shows the information, but I need only certain columns to appear.
The other thing is that I don't know what other option I have to create DataGrids
VERY VERY IMPORTANT, DO NOT CREATE EMPTY COLUMNS, WITHOUT LINKING, IF YOU CRACK IT WILL GENERATE AN ERROR AND THE LIST WILL NOT LOAD, IF YOU CREATE 3 COLUMNS, YOU MUST LINK TO THE LIST IN THE THREE COLUMNS
First things first: we will see what documentation we have on this, there are two OpenSource libraries that allow us to generate DataGrids in UWP, I understand that the DataGrid cannot be native within the UWP development environment, so when reviewing we see that it has 2 forms this first link:
1- Documentation page: https://github.com/RSuter/MyToolkit/wiki/DataGrid
This is very easy to upload easily:
Download the NuGet: https://www.nuget.org/packages/MyToolkit.Extended/
or look in the NuGet window: "MyToolkit.Extended" and install
import usage in XAML:
xmlns:controls="using:MyToolkit.Controls"
The name Plactas is the list in the VIEWMODEL and is declared like thisThis is the XAML Code of the List:
EASY!!! but this layout may not catch your eye, don't worry, that's why I'm here, there is another OpenSource library... so we'll see a second option
2- Documentation page: https://docs.microsoft.com/en-us/windows/communitytoolkit/controls/datagrid
Download the NuGet: https://github.com/Microsoft/WindowsCommunityToolkit
or look in the NuGet window: "Microsoft.Toolkit.Uwp.UI.Controls.DataGrid" and install
import use in XAML:
xmlns:control="using:Microsoft.Toolkit.Uwp.UI.Controls"
Create code in XAML:
With this, the list would be loaded in the DataGrid
The good thing about this type of DataGrid is that it allows much better editing, here is the documentation so you can see the fields and lines: https://docs.microsoft.com/es-es/windows/communitytoolkit/controls / datagrid_guidance / styling_formatting_options
This is the result:
Above the first DataGrid layout:
And this is the second design: