MainWindow.xaml 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <Window x:Class="WpfApp1.MainWindow"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  5. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  6. xmlns:local="clr-namespace:WpfApp1"
  7. mc:Ignorable="d"
  8. Title="Иванов Валера И-211" Height="450" Width="908">
  9. <Window.Resources>
  10. <Style
  11. x:Key="StackStyle"
  12. TargetType="ListBox">
  13. <Setter Property="ItemsPanel">
  14. <Setter.Value>
  15. <ItemsPanelTemplate>
  16. <StackPanel
  17. Orientation="Vertical"/>
  18. </ItemsPanelTemplate>
  19. </Setter.Value>
  20. </Setter>
  21. </Style>
  22. <Style
  23. x:Key="WrapStyle"
  24. TargetType="ListBox">
  25. <Setter Property="ItemsPanel">
  26. <Setter.Value>
  27. <ItemsPanelTemplate>
  28. <WrapPanel
  29. HorizontalAlignment="Center"
  30. ItemWidth="200"/>
  31. </ItemsPanelTemplate>
  32. </Setter.Value>
  33. </Setter>
  34. </Style>
  35. <Style
  36. TargetType="Button">
  37. <Setter
  38. Property="FontFamily"
  39. Value="Verdana" />
  40. <Setter
  41. Property="Background"
  42. Value="Black" />
  43. <Setter
  44. Property="Foreground"
  45. Value="White" />
  46. <Setter
  47. Property="Margin"
  48. Value="10" />
  49. </Style>
  50. </Window.Resources>
  51. <Grid ShowGridLines="True">
  52. <Grid.RowDefinitions>
  53. <RowDefinition Height="auto"/>
  54. <RowDefinition />
  55. <RowDefinition Height="auto"/>
  56. </Grid.RowDefinitions>
  57. <Grid.ColumnDefinitions>
  58. <ColumnDefinition Width="200"/>
  59. <ColumnDefinition/>
  60. </Grid.ColumnDefinitions>
  61. <!-- лого -->
  62. <Image
  63. Source="./bin/Debug/net8.0-windows/img/net.jpg"
  64. Grid.RowSpan="2" HorizontalAlignment="Right"/>
  65. <ListBox
  66. x:Name="carListBox"
  67. Style="{StaticResource StackStyle}"
  68. Grid.Row="1"
  69. Grid.Column="1"
  70. Background="White"
  71. ItemsSource="{Binding CarList}"
  72. ScrollViewer.HorizontalScrollBarVisibility="Disabled">
  73. <ListBox.ItemContainerStyle>
  74. <Style
  75. TargetType="ListBoxItem">
  76. <Setter
  77. Property="HorizontalContentAlignment"
  78. Value="Stretch" />
  79. </Style>
  80. </ListBox.ItemContainerStyle>
  81. <ListBox.ItemTemplate>
  82. <DataTemplate>
  83. <Border
  84. BorderThickness="1"
  85. BorderBrush="Black"
  86. CornerRadius="5">
  87. <Grid
  88. Margin="10"
  89. HorizontalAlignment="Stretch">
  90. <Grid.ColumnDefinitions>
  91. <ColumnDefinition Width="64"/>
  92. <ColumnDefinition Width="*"/>
  93. <ColumnDefinition Width="auto"/>
  94. </Grid.ColumnDefinitions>
  95. <Image
  96. Width="64"
  97. Height="64"
  98. Source="{Binding ImageBitmap}" />
  99. <StackPanel
  100. Grid.Column="1"
  101. Margin="5"
  102. Orientation="Vertical">
  103. <TextBlock
  104. Text="{Binding name}"/>
  105. <TextBlock
  106. Text="{Binding price}"/>
  107. </StackPanel>
  108. <TextBlock
  109. Grid.Column="2"
  110. Text="{Binding year}"/>
  111. </Grid>
  112. </Border>
  113. </DataTemplate>
  114. </ListBox.ItemTemplate>
  115. </ListBox>
  116. <StackPanel
  117. Orientation="Vertical"
  118. Grid.RowSpan="3"
  119. VerticalAlignment="Bottom">
  120. <Button
  121. Background="LightSeaGreen"
  122. x:Name="ExitButton"
  123. Content="Выход"
  124. Click="ExitButton_Click"
  125. Height="50"/>
  126. </StackPanel>
  127. <WrapPanel
  128. Orientation="Horizontal"
  129. Grid.Column="1"
  130. MinHeight="50">
  131. <Button Content="Переключить вид" Click="ToggleView_Click"/>
  132. <Label
  133. Content="Поиск"
  134. VerticalAlignment="Center"/>
  135. <TextBox
  136. Width="200"
  137. VerticalAlignment="Center"
  138. x:Name="SearchFilterTextBox"
  139. KeyUp="SearchFilter_KeyUp"/>
  140. <Label
  141. Content="Название:"
  142. VerticalAlignment="Center"/>
  143. <ComboBox
  144. Name="carnameFilterComboBox"
  145. SelectionChanged="carnameFilterComboBox_SelectionChanged"
  146. VerticalAlignment="Center"
  147. MinWidth="100"
  148. SelectedIndex="0"
  149. ItemsSource="{Binding CarinfoList}">
  150. <ComboBox.ItemTemplate>
  151. <DataTemplate>
  152. <Label
  153. Content="{Binding title}"/>
  154. </DataTemplate>
  155. </ComboBox.ItemTemplate>
  156. </ComboBox>
  157. <Label
  158. Content="Цена:"
  159. VerticalAlignment="Center"/>
  160. <ComboBox
  161. Name="carpriceFilterComboBox"
  162. SelectionChanged="carpriceFilterComboBox_SelectionChanged"
  163. VerticalAlignment="Center"
  164. MinWidth="100"
  165. SelectedIndex="0"
  166. ItemsSource="{Binding CarpriceList}">
  167. <ComboBox.ItemTemplate>
  168. <DataTemplate>
  169. <Label
  170. Content="{Binding title}"/>
  171. </DataTemplate>
  172. </ComboBox.ItemTemplate>
  173. </ComboBox>
  174. <Label
  175. Content="Возраст:"
  176. VerticalAlignment="Center"/>
  177. <RadioButton
  178. GroupName="Age"
  179. Tag="1"
  180. Content="по возрастанию"
  181. IsChecked="True"
  182. Checked="RadioButton_Checked"
  183. VerticalAlignment="Center"/>
  184. <RadioButton
  185. GroupName="Age"
  186. Tag="2"
  187. Content="по убыванию"
  188. Checked="RadioButton_Checked"
  189. VerticalAlignment="Center"/>
  190. </WrapPanel>
  191. </Grid>
  192. </Window>