I hope that you are familiar with data bindings (binding). Compiled data bindings have appeared in UWP applications that work faster. Create a class with a data structure.
public class ClassInfo { private string _name; private int _surname; public string Name { get { return _name; } set { _name = value;} } public int Surname { get { return _surname; } set { _surname = value;} } }
Next in XAML, add a GridView or, as in the following example, a ListView with a single item template inside:
<ListView ItemsSource="{x:Bind mydata}" Width="200" Height="500"> <ListView.ItemTemplate> <DataTemplate x:DataType="local:ClassInfo"> <StackPanel Orientation="Vertical"> <TextBlock Text="{x:Bind Name}" x:Phase="0" ></TextBlock> <TextBlock Text="{x:Bind Surname}" x:Phase="1" ></TextBlock> </StackPanel> </DataTemplate> </ListView.ItemTemplate>
You will need not a simple collection, but an Observable (as it changes the UI, the XAML changes as well):
ObservableCollection<ImageInfo> mydata = new ObservableCollection<ImageInfo>();
If you look at XAML, then the data is attached to it - ItemsSource = "{x: Bind mydata}".
Well, somewhere in the code you can now set the data context:
this.DataContext = mydata;
and add some data:
mydata.Add(new ClassInfo { Name = "Алексей", Surname = "Соммер" });
If you are interested in how to select data from SQLite in UWP, you can do this using the SQLite for Universal Windows Platform. Download and install vsix. Add link and namespace
using SQLitePCL;
And read the data in a loop
using (var statement = conn.Prepare("SELECT Name, Surname FROM People WHERE FirstName='Alex'")) { while (statement.Step() == SQLiteResult.ROW) { mydata.Add(new ClassInfo { Name = (string)statement[0], Surname = (string)statement[1] }); } }