I'm using a database with sqlite
already done and with data in my application UWP
and trying to display in listview
the data that is in the Marcas
table.
What I have done so far was to create a class Marcas
:
public class Marcas
{
public string Nome { get; set; }
public string Imagem { get; set; }
public string Descricao { get; set; }
}
I created a listview
on screen
<ListView x:Name="listView" HorizontalAlignment="Left"
Height="800" VerticalAlignment="Top" Width="500">
<ListView.Header>
<StackPanel Height="100" Width="100">
<TextBlock Text="{Binding Nome}"/>
<TextBlock Text="{Binding Imagem}"/>
<TextBlock Text="{Binding Descricao}"/>
</StackPanel>
</ListView.Header>
</ListView>
The property:
public ObservableCollection<Marcas> obs_Marcas { get; set; }
and the method to get the bank records:
List<Marcas> oMarcas = conn.Query<Marcas>("Select * From Marcas");
obs_Marcas = new ObservableCollection<Marcas>();
foreach (Marcas marca in oMarcas)
{
obs_Marcas.Add(new Marcas { Nome = marca.Nome,
Descricao = marca.Descricao,
Imagem = marca.Imagem
}
);
}
listView.ItemsSource = obs_Marcas;
By debugging, the obs_Marcas
object is filled in correctly with the database data. At the time of obs_Marcas.Add
, name, description and image are being filled correctly, but in the application the list gets all records as GeraBanner.Marcas
.
What did I do wrong and how to display the data correctly?