I have use sqlite and visualstudio 2015. I have displayed the required data using listview.
Now i want to display data of only the selected item in listview when i click the display the data(Button).
when i click showdata button(btnAdd_Click) listview is displayed.
Display.xaml
- <Grid Background="Gray">
- <Button x:Name="btn" Click="btnAdd_Click" Content="Showdata" Width="200" Margin="900,43,0,687" Background="#FF040404" />
- <ListView Header="Detailss" x:Name="myList" HorizontalAlignment="Left">
- <ListView.ItemTemplate>
- <DataTemplate>
- <StackPanel Orientation="Vertical" Height="150" Width="200" Background="White">
- <TextBlock x:Name="username" HorizontalAlignment="Left" Text="{Binding Username}" TextWrapping="Wrap" Foreground="Black" />
- <TextBlock x:Name="password" Text="{Binding Password}" TextWrapping="Wrap" Foreground="Black" />
- <TextBlock x:Name="name" Text="{Binding Name}" TextWrapping="Wrap" Foreground="Black" />
- <TextBlock x:Name="address" Text="{Binding Address}" TextWrapping="Wrap" Foreground="Black"/>
- <Button x:Name="btn1" Content="Display This Data" Background="#FFA68A8A" Foreground="#FF060606" Click="btn1Add_Click"/>
- </StackPanel>
- </DataTemplate>
- </ListView.ItemTemplate>
- </ListView>
Display.xaml.cs
- string DB_Path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "Winapp.sqlite");
- private void btnAdd_Click(object sender, RoutedEventArgs e)
- {
- ObservableCollection<RegisterTable> obsregtable = new ObservableCollection<RegisterTable>();
- using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), DB_Path))
- {
- List<RegisterTable> RegisterData = conn.Query<RegisterTable>("select * from RegisterTable");
- foreach (var item in RegisterData)
- {
- obsregtable.Add(new RegisterTable() { Id = item.Id, Name = item.Name, Username = item.Username, Password = item.Password, Address = item.Address });
- }
- myList.ItemsSource = obsregtable;
- }
- private async void btn1Add_Click(object sender, RoutedEventArgs e)
- {
- }