Popular Listview UWP C #

1

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?

    
asked by anonymous 17.08.2017 / 22:35

1 answer

0

The% used with problems , I've posted one that can be a% recommend for your problem and will bring the information in each separate in> :

<ListView x:Name="listView"  HorizontalAlignment="Left" 
          Height="800" VerticalAlignment="Top" Width="500">
    <ListView.ItemTemplate>
        <DataTemplate>
            <StackPanel Height="100" Width="100">
                <TextBlock Text="{Binding Nome}"/>
                <TextBlock Text="{Binding Imagem}"/>
                <TextBlock Text="{Binding Descricao}"/>
            </StackPanel>
        </DataTemplate>
    </ListView.ItemTemplate>           
</ListView>

18.08.2017 / 01:18