I have a button which when selected, pulls one gif image from the database to display in a listbox. I'm trying to have this action repeated, where every time the user selects the button, the new gif is added to the other gifs already contained in the listbox. How can this be achieved? Below is the code I've tried in the button. Thanks in advance
private void Btn_Click(object sender, RoutedEventArgs e)
{ SQLiteConnection sqliteCon = new SQLiteConnection(dbConnectionString);
sqliteCon.Open();
string GifsSelectionQuery = "SELECT gif FROM myTable WHERE Style = 'Jump'"; SQLiteDataAdapter adapter = new SQLiteDataAdapter(GifsSelectionQuery, sqliteCon); DataTable dt = new DataTable(); adapter.Fill(dt); SQLiteDataReader dataReader1 = GifsCommand.ExecuteReader(); myListBox.ItemsSource = dt.DefaultView;
}
the xaml:
<ListBox Name="myListBox" Height="150" Width="250" Margin="10,25,0,0"xmlns:local="clr-namespace:ModernUINavigationApp1" HorizontalAlignment="Left">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Image gif:ImageBehavior.AutoStart="True" Height="70" Width="70"
gif:ImageBehavior.RepeatBehavior="Forever"
gif:ImageBehavior.AnimatedSource="{Binding Path=gif}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>