ProductsUserControl.xaml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <UserControl x:Class="OOO_WriteAndClear.MVP.Views.ProductsUserControl"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:local="clr-namespace:OOO_WriteAndClear.MVP.Views"
  7. xmlns:db_models="clr-namespace:OOO_WriteAndClear.DBModels"
  8. mc:Ignorable="d"
  9. d:DesignHeight="450" d:DesignWidth="800"
  10. FontFamily="Comic Sans MS"
  11. Background="White"
  12. Loaded="UserControlWasLoaded">
  13. <UserControl.Resources>
  14. <Style x:Key="ProductsUserControl.ProductList" TargetType="ListView">
  15. <Setter Property="BorderThickness" Value="0"/>
  16. <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
  17. <Setter Property="ItemTemplate">
  18. <Setter.Value>
  19. <DataTemplate DataType="db_models:Product">
  20. <Border Padding="10" HorizontalAlignment="Stretch">
  21. <Border.Style>
  22. <Style TargetType="Border">
  23. <Style.Triggers>
  24. <DataTrigger Binding="{Binding IsBiggerThan15PercentDiscount}" Value="true">
  25. <Setter Property="Background" Value="#7fff00"/>
  26. </DataTrigger>
  27. </Style.Triggers>
  28. </Style>
  29. </Border.Style>
  30. <Grid>
  31. <Grid.ColumnDefinitions>
  32. <ColumnDefinition Width="auto"/>
  33. <ColumnDefinition />
  34. <ColumnDefinition Width="auto"/>
  35. </Grid.ColumnDefinitions>
  36. <Image Grid.Column="0" Margin="0 0 10 0"
  37. Width="150" Height="120"
  38. HorizontalAlignment="Center"
  39. Source="{Binding ProductImage}"/>
  40. <StackPanel Grid.Column="1"
  41. Orientation="Vertical">
  42. <Label Padding="0" Content="{Binding ProductName}"/>
  43. <TextBlock TextWrapping="WrapWithOverflow"
  44. Text="{Binding ProductDescription}"/>
  45. <StackPanel Orientation="Horizontal">
  46. <Label Padding="0"
  47. Content="Производитель: "/>
  48. <TextBlock Text="{Binding ProductManufacturer.ManufacturerName}"/>
  49. </StackPanel>
  50. <StackPanel Orientation="Horizontal">
  51. <Label Padding="0"
  52. Content="Цена:"/>
  53. <StackPanel Orientation="Horizontal">
  54. <TextBlock Text="{Binding ProductCost, StringFormat={}{0:f2}}"
  55. TextDecorations="Strikethrough"
  56. Margin="0 0 5 0">
  57. <TextBlock.Style>
  58. <Style TargetType="TextBlock">
  59. <Style.Triggers>
  60. <DataTrigger Binding="{Binding ProductDiscountAmount}" Value="{x:Null}">
  61. <Setter Property="Visibility" Value="Collapsed"/>
  62. </DataTrigger>
  63. <DataTrigger Binding="{Binding ProductDiscountAmount}" Value="0">
  64. <Setter Property="Visibility" Value="Collapsed"/>
  65. </DataTrigger>
  66. </Style.Triggers>
  67. </Style>
  68. </TextBlock.Style>
  69. </TextBlock>
  70. <TextBlock Text="{Binding CurrentPrice, StringFormat={}{0:f2} руб.}"/>
  71. </StackPanel>
  72. </StackPanel>
  73. </StackPanel>
  74. <TextBlock Grid.Column="2"
  75. Margin="10 0 0 0"
  76. VerticalAlignment="Center" HorizontalAlignment="Center"
  77. Text="{Binding ProductDiscountMax, StringFormat={}{0:f2}%}"/>
  78. </Grid>
  79. </Border>
  80. </DataTemplate>
  81. </Setter.Value>
  82. </Setter>
  83. </Style>
  84. <Style x:Key="BackButtonStyle" TargetType="{x:Type Button}">
  85. <Setter Property="Width" Value="35"/>
  86. <Setter Property="Height" Value="35"/>
  87. <Setter Property="Margin" Value="0 0 0 10"/>
  88. <Setter Property="VerticalAlignment" Value="Top"/>
  89. <Setter Property="Template">
  90. <Setter.Value>
  91. <ControlTemplate TargetType="{x:Type Button}">
  92. <Image Height="{TemplateBinding Height}"
  93. Width="{TemplateBinding Width}"
  94. Source="/Assets/Pictures/BackButton.png"/>
  95. </ControlTemplate>
  96. </Setter.Value>
  97. </Setter>
  98. </Style>
  99. </UserControl.Resources>
  100. <Border Padding="10">
  101. <Grid>
  102. <Grid.RowDefinitions>
  103. <RowDefinition Height="auto"/>
  104. <RowDefinition Height="auto"/>
  105. <RowDefinition/>
  106. </Grid.RowDefinitions>
  107. <Label Grid.Row="0"
  108. Margin="0 0 0 15"
  109. FontSize="18" FontWeight="Bold"
  110. Content="Товары"
  111. HorizontalAlignment="Center" VerticalAlignment="Top"/>
  112. <Grid HorizontalAlignment="Right" VerticalAlignment="Top"
  113. Margin="0 0 10 0">
  114. <Grid.ColumnDefinitions>
  115. <ColumnDefinition Width="auto"/>
  116. <ColumnDefinition/>
  117. </Grid.ColumnDefinitions>
  118. <Grid.RowDefinitions>
  119. <RowDefinition Height="auto"/>
  120. <RowDefinition Height="auto"/>
  121. </Grid.RowDefinitions>
  122. <Image Grid.Column="0" Grid.RowSpan="2"
  123. Height="40" Width="40"
  124. VerticalAlignment="Top"
  125. Margin="0 0 10 0"
  126. Source="/Assets/Pictures/LoginFieldIcon.png"/>
  127. <TextBlock x:Name="DisplayingUserName"
  128. Grid.Column="1" Grid.Row="0"
  129. Text="Гость"
  130. Margin="0 0 0 5"/>
  131. <TextBlock x:Name="DisplayingUserRole"
  132. Grid.Column="1" Grid.Row="1"
  133. Foreground="Gray"/>
  134. </Grid>
  135. <Button Style="{DynamicResource BackButtonStyle}"
  136. HorizontalAlignment="Left" VerticalAlignment="Top"
  137. Click="ReturnBack_ButtonClick" />
  138. <Grid Grid.Row="1" HorizontalAlignment="Stretch">
  139. <Grid.RowDefinitions>
  140. <RowDefinition/>
  141. <RowDefinition/>
  142. </Grid.RowDefinitions>
  143. <TextBox x:Name="SearchBar"
  144. Grid.Row="0"
  145. Margin="0 0 0 10"
  146. Width="400"
  147. HorizontalAlignment="Left"
  148. TextChanged="SearchBarTextWasChanged"/>
  149. <StackPanel Grid.Row="0"
  150. Orientation="Horizontal"
  151. HorizontalAlignment="Right">
  152. <TextBlock x:Name="DisplayingProductsCount"
  153. Text="0"/>
  154. <TextBlock Text=" из "/>
  155. <TextBlock x:Name="AllProductsCount"
  156. Text="0"/>
  157. </StackPanel>
  158. <StackPanel Grid.Row="1"
  159. Margin="0 0 0 10"
  160. Orientation="Horizontal">
  161. <GroupBox Margin="0 0 10 0"
  162. Header="Фильтрация по скидке">
  163. <ComboBox x:Name="FilterComboBox"
  164. SelectionChanged="FilterComboBoxSelectionWasChanged"/>
  165. </GroupBox>
  166. <GroupBox Header="Сортировка по цене">
  167. <ComboBox x:Name="SortComboBox"
  168. SelectionChanged="SortComboBoxSelectionWasChanged"/>
  169. </GroupBox>
  170. </StackPanel>
  171. <Button x:Name="GoToBasketButton"
  172. Grid.Row="1"
  173. Background="#498c51" BorderThickness="0" Foreground="White"
  174. Margin="0 0 0 10"
  175. HorizontalAlignment="Right" VerticalAlignment="Stretch"
  176. Visibility="Hidden" Click="GoToOrderCart_ButtonClick">
  177. <Button.Content>
  178. <StackPanel Orientation="Horizontal">
  179. <Label Content="В корзину:"/>
  180. <Label x:Name="BasketCostLabel"
  181. Content="0 Руб."/>
  182. </StackPanel>
  183. </Button.Content>
  184. </Button>
  185. </Grid>
  186. <ListView x:Name="ProductsList"
  187. Grid.Row="2" HorizontalAlignment="Stretch"
  188. Style="{StaticResource ProductsUserControl.ProductList}"
  189. d:ItemsSource="{d:SampleData ItemCount=5}">
  190. <ListView.ContextMenu>
  191. <ContextMenu>
  192. <MenuItem Header="Добавить к заказу"
  193. Click="AddProductToOrder_Button"/>
  194. <MenuItem Header="Убрать из заказа"
  195. Click="RemoveProductFromOrder_Button"/>
  196. </ContextMenu>
  197. </ListView.ContextMenu>
  198. </ListView>
  199. </Grid>
  200. </Border>
  201. </UserControl>