|
|
|
|
<Window x:Class="ListBoxLinqBindingSample.MainWindow"
|
|
|
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
|
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
|
|
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
|
|
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
|
|
|
xmlns:local="clr-namespace:ListBoxLinqBindingSample"
|
|
|
|
|
xmlns:viewModel="clr-namespace:ListBoxLinqBindingSample.ViewModel"
|
|
|
|
|
mc:Ignorable="d"
|
|
|
|
|
Title="MainWindow" Height="400" Width="450">
|
|
|
|
|
<Window.Resources>
|
|
|
|
|
<viewModel:Duties x:Key="duties"/>
|
|
|
|
|
<DataTemplate x:Key="myTemplate">
|
|
|
|
|
<Border x:Name="boarder">
|
|
|
|
|
<Grid>
|
|
|
|
|
<Grid.RowDefinitions>
|
|
|
|
|
<RowDefinition/>
|
|
|
|
|
<RowDefinition/>
|
|
|
|
|
<RowDefinition/>
|
|
|
|
|
</Grid.RowDefinitions>
|
|
|
|
|
<Grid.ColumnDefinitions>
|
|
|
|
|
<ColumnDefinition/>
|
|
|
|
|
<ColumnDefinition/>
|
|
|
|
|
</Grid.ColumnDefinitions>
|
|
|
|
|
|
|
|
|
|
<TextBlock Grid.Column="0" Grid.Row="0" Text="Duty name: "/>
|
|
|
|
|
<TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding Name}"/>
|
|
|
|
|
<TextBlock Grid.Column="0" Grid.Row="1" Text="Duty type: "/>
|
|
|
|
|
<TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding DutyType}"/>
|
|
|
|
|
<Separator Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2"/>
|
|
|
|
|
</Grid>
|
|
|
|
|
</Border>
|
|
|
|
|
</DataTemplate>
|
|
|
|
|
<LinearGradientBrush x:Key="myGradientBrush" StartPoint="0,0" EndPoint="1,1">
|
|
|
|
|
<GradientStop Color="DarkSeaGreen" Offset="0"/>
|
|
|
|
|
<GradientStop Color="LawnGreen" Offset="0.5"/>
|
|
|
|
|
<GradientStop Color="DarkSeaGreen" Offset="1"/>
|
|
|
|
|
</LinearGradientBrush>
|
|
|
|
|
<Style TargetType="Button">
|
|
|
|
|
<Setter Property="Background" Value="{StaticResource myGradientBrush}"/>
|
|
|
|
|
<Setter Property="Width" Value="80"/>
|
|
|
|
|
<Setter Property="Margin" Value="5"/>
|
|
|
|
|
</Style>
|
|
|
|
|
</Window.Resources>
|
|
|
|
|
|
|
|
|
|
<StackPanel Margin="10">
|
|
|
|
|
<Button x:Name="btnAdd" Content="Duty registration" Width="200"
|
|
|
|
|
Click="btnAdd_Click"/>
|
|
|
|
|
<TextBlock Text="Select duty type"/>
|
|
|
|
|
<ListBox x:Name="lstType"
|
|
|
|
|
SelectedIndex="0"
|
|
|
|
|
SelectionChanged="lstType_SelectionChanged">
|
|
|
|
|
<ListBoxItem Content="Inside"/>
|
|
|
|
|
<ListBoxItem Content="Outside"/>
|
|
|
|
|
</ListBox>
|
|
|
|
|
<TextBlock Margin="10 10 0 10" Text="Duty"/>
|
|
|
|
|
<ListBox x:Name="lstMain" Width="400" Margin="10" HorizontalContentAlignment="Stretch"
|
|
|
|
|
ItemTemplate="{StaticResource myTemplate}"
|
|
|
|
|
ItemsSource="{Binding}"
|
|
|
|
|
SelectionChanged="lstMain_SelectionChanged"/>
|
|
|
|
|
</StackPanel>
|
|
|
|
|
</Window>
|