<Window x:Class="CollectionBinding.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:data="clr-namespace:ClassLibrary;assembly=ClassLibrary"
xmlns:local="clr-namespace:CollectionBinding"
Title="MainWindow" Height="523.038" Width="361.701">
<Window.Resources>
<ObjectDataProvider IsAsynchronous="True" ObjectType="{x:Type data:StoreDB}" MethodName="GetProducts" x:Key="DataProvider"></ObjectDataProvider>
<local:PriceConverter x:Key="PriceConverter"></local:PriceConverter>
<local:ImageConverter x:Key="ImageConverter"></local:ImageConverter>
<local:PriceToBrushConverter Min="10" Max="100" x:Key="PriceToBrushConverter"></local:PriceToBrushConverter>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<ListBox Margin="3" Grid.Row="0" Name="lstProducts" Height="120"
ScrollViewer.VerticalScrollBarVisibility="Visible" ItemsSource="{Binding Source={StaticResource DataProvider}}"
DisplayMemberPath="ModelName" AlternationCount="3">
<ListBox.ItemContainerStyle>
<Style>
<Setter Property="ListBoxItem.Background" Value="LightSteelBlue"></Setter>
<Setter Property="ListBoxItem.Margin" Value="5"></Setter>
<Setter Property="ListBoxItem.Padding" Value="3"></Setter>
<Style.Triggers>
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
<Setter Property="ListBoxItem.Background" Value="LightBlue"></Setter>
</Trigger>
<Trigger Property="ItemsControl.AlternationIndex" Value="2">
<Setter Property="ListBoxItem.Background" Value="Brown"></Setter>
</Trigger>
<Trigger Property="ListBoxItem.IsSelected" Value="True">
<Setter Property="ListBoxItem.Background" Value="DarkRed"></Setter>
<Setter Property="ListBoxItem.Foreground" Value="White"></Setter>
<Setter Property="ListBoxItem.BorderBrush" Value="Red"></Setter>
<Setter Property="ListBoxItem.BorderThickness" Value="2"></Setter>
</Trigger>
</Style.Triggers>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
<StackPanel Margin="3" Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Margin="3" MinWidth="100" Name="btnGetProducts" Click="btnGetProducts_Click_1">GetProducts</Button>
</StackPanel>
<Grid Margin="3" Name="grid" Grid.Row="2" DataContext="{Binding ElementName=lstProducts,Path=SelectedItem}"
Background="{Binding Path=UnitCost, Converter={StaticResource PriceToBrushConverter}}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Margin="3" Grid.Row="0" Grid.Column="0">CategoryID:</TextBlock>
<TextBox Name="txtCategoryID" Margin="3" Grid.Row="0" Grid.Column="1" Text="{Binding Path=CategoryID}"></TextBox>
<TextBlock Margin="3" Grid.Row="1" Grid.Column="0">ModelNumber:</TextBlock>
<TextBox Name="txtModelNumber" Margin="3" Grid.Row="1" Grid.Column="1" Text="{Binding Path=ModelNumber}"></TextBox>
<TextBlock Margin="3" Grid.Row="2" Grid.Column="0">ModelName:</TextBlock>
<TextBox Name="txtModelName" Margin="3" Grid.Row="2" Grid.Column="1" Text="{Binding Path=ModelName}"></TextBox>
<TextBlock Margin="3" Grid.Row="3" Grid.Column="0">ProductImage:</TextBlock>
<Border Grid.Row="3" Grid.Column="1" Margin="3" BorderBrush="Black" BorderThickness="1" Width="100" Height="100" >
<Image Source="{Binding Path=ProductImage,Converter={StaticResource ImageConverter}}"></Image>
</Border>
<TextBlock Margin="3" Grid.Row="4" Grid.Column="0">UnitCost:</TextBlock>
<TextBox Name="txtUnitCost" Margin="3" Grid.Row="4" Grid.Column="1" Text="{Binding Path=UnitCost,Converter={StaticResource PriceConverter}}">
</TextBox>
<TextBox Name="txtDescription" Margin="3" Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="2" TextWrapping="Wrap"
Text="{Binding Path=Description}" ScrollViewer.VerticalScrollBarVisibility="Visible"></TextBox>
</Grid>
</Grid>
</Window>