Xaml: <Window.Resources> <CollectionViewSource x:Key="eventsViewSource" Source="{Binding Events}"/> </Window.Resources> <Grid> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition/> <RowDefinition/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition/> <ColumnDefinition/> </Grid.ColumnDefinitions> <ListView ItemsSource="{Binding Source={StaticResource eventsViewSource}}" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" Grid.RowSpan="2" ScrollViewer.HorizontalScrollBarVisibility="Disabled" Name="EventsListView"> <ListView.ItemsPanel> <ItemsPanelTemplate> <WrapPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center"/> </ItemsPanelTemplate> </ListView.ItemsPanel> <ListView.ItemTemplate> <DataTemplate> <Grid Width="240"> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition/> <RowDefinition/> <RowDefinition/> <RowDefinition/> </Grid.RowDefinitions> <Image Stretch="Uniform" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="1" Height="150" Width="150" Source="{Binding Path=Photo}" /> <TextBlock Grid.Row="1" TextWrapping="Wrap" Margin="0 5 0 0" TextAlignment="Center" FontSize="14" Text="{Binding Path=EventName}" HorizontalAlignment="Center"/> <TextBlock Grid.Row="3" Margin="0 5 0 0" TextAlignment="Center" FontSize="14" Text="{Binding Path=Date,StringFormat=d}" HorizontalAlignment="Center"/> <TextBlock Grid.Row="4" Margin="0 5 0 0" TextAlignment="Center" FontSize="14" Text="{Binding name}" HorizontalAlignment="Center"/> </Grid> </DataTemplate> </ListView.ItemTemplate> </ListView> CSharp: using (var connection = new SqlConnection("Server=(localdb)\\mssqllocaldb;Database=shoidaaaaaaaaaa;")) { SqlCommand command = new SqlCommand("SELECT * FROM Event INNER JOIN Directions ON Event.id = Directions.id", connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); DataTable dataTable = new DataTable(); dataTable.Load(reader); // Load data from SqlDataReader into DataTable EventsListView.ItemsSource = dataTable.DefaultView; // Set DataTable as ItemsSource connection.Close(); }
License
—
Deps
0
Install Size
—
Vulns
✓ 0
Published
May 26, 2024
$ dotnet add package GimleGibness2No README available.