MainWindow.xaml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <Window x:Class="wpf_listbox.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:wpf_listbox"
  7. mc:Ignorable="d"
  8. Title="MainWindow" Height="450" Width="880" >
  9. <Window.Resources>
  10. <BitmapImage
  11. x:Key='defaultImage'
  12. UriSource='./img/1.webp' />
  13. <Style
  14. TargetType="Button">
  15. <Setter
  16. Property="FontFamily"
  17. Value="Verdana" />
  18. <Setter
  19. Property="Background"
  20. Value="PapayaWhip" />
  21. <Setter
  22. Property="Foreground"
  23. Value="Peru" />
  24. <Setter
  25. Property="Margin"
  26. Value="10" />
  27. <EventSetter
  28. Event="Button.Click"
  29. Handler="Button_Click" />
  30. </Style>
  31. </Window.Resources>
  32. <Grid ShowGridLines="True">
  33. <Grid.RowDefinitions>
  34. <RowDefinition Height="auto"/>
  35. <RowDefinition />
  36. <RowDefinition Height="auto"/>
  37. </Grid.RowDefinitions>
  38. <Grid.ColumnDefinitions>
  39. <ColumnDefinition Width="200"/>
  40. <ColumnDefinition/>
  41. </Grid.ColumnDefinitions>
  42. <!-- типа логотип компании -->
  43. <Image
  44. Source="./img/1.webp"
  45. Grid.RowSpan="2" HorizontalAlignment="Right"/>
  46. <StackPanel
  47. x:Name="buttonsStack"
  48. Background="NavajoWhite" >
  49. <Button
  50. x:Name="button1"
  51. Content="Кнопка 1" />
  52. <Button
  53. x:Name="button2"
  54. Content="Кнопка 2" />
  55. </StackPanel>
  56. <ListBox
  57. Grid.Column="1"
  58. Grid.Row="1"
  59. Background="White"
  60. ItemsSource="{Binding PeopleList}" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
  61. <ListBox.ItemsPanel>
  62. <ItemsPanelTemplate>
  63. <WrapPanel
  64. HorizontalAlignment="Center" />
  65. </ItemsPanelTemplate>
  66. </ListBox.ItemsPanel>
  67. <ListBox.ItemTemplate>
  68. <DataTemplate>
  69. <Border
  70. BorderThickness="1"
  71. BorderBrush="Black"
  72. CornerRadius="5">
  73. <Grid Width="200"
  74. Margin="10"
  75. HorizontalAlignment="Stretch">
  76. <Grid.ColumnDefinitions>
  77. <ColumnDefinition Width="64"/>
  78. <ColumnDefinition Width="*"/>
  79. <ColumnDefinition Width="auto"/>
  80. </Grid.ColumnDefinitions>
  81. <Image
  82. Width="64"
  83. Height="64"
  84. Source="{Binding ImageBitmap,TargetNullValue={StaticResource defaultImage}}" />
  85. <StackPanel
  86. Grid.Column="1"
  87. Margin="5"
  88. Orientation="Vertical">
  89. <TextBlock
  90. Text="{Binding Name}"/>
  91. <TextBlock
  92. Text="{Binding Price}"/>
  93. <TextBlock
  94. Text="{Binding Place}"/>
  95. </StackPanel>
  96. <TextBlock
  97. Grid.Column="2"
  98. Text="{Binding Age}"/>
  99. </Grid>
  100. </Border>
  101. </DataTemplate>
  102. </ListBox.ItemTemplate>
  103. </ListBox>
  104. <StackPanel
  105. Orientation="Vertical"
  106. Grid.RowSpan="3"
  107. VerticalAlignment="Bottom">
  108. <Button
  109. x:Name="ExitButton"
  110. Content="Выход"
  111. Click="ExitButton_Click"
  112. Height="50"/>
  113. </StackPanel>
  114. <WrapPanel
  115. Orientation="Horizontal"
  116. Grid.Column="1"
  117. MinHeight="50">
  118. <Label
  119. Content="искать"
  120. VerticalAlignment="Center"/>
  121. <TextBox
  122. Width="200"
  123. VerticalAlignment="Center"
  124. x:Name="SearchFilterTextBox"
  125. KeyUp="SearchFilter_KeyUp"/>
  126. <ComboBox
  127. Name="GenderFilterComboBox"
  128. SelectionChanged="GenderFilterComboBox_SelectionChanged_1"
  129. VerticalAlignment="Center"
  130. MinWidth="100"
  131. SelectedIndex="0"
  132. ItemsSource="{Binding PeopleGenderList}">
  133. <ComboBox.ItemTemplate>
  134. <DataTemplate>
  135. <Label
  136. Content="{Binding title}"/>
  137. </DataTemplate>
  138. </ComboBox.ItemTemplate>
  139. </ComboBox>
  140. <Label
  141. Content="Возраст:"
  142. VerticalAlignment="Center"/>
  143. <ComboBox
  144. Name="AgeFilterComboBox"
  145. SelectionChanged="AgeFilterComboBox_SelectionChanged_2"
  146. VerticalAlignment="Center"
  147. MinWidth="100"
  148. SelectedIndex="0"
  149. ItemsSource="{Binding PeopleAgeList}">
  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="PlaceFilterComboBox"
  162. SelectionChanged="PlaceFilterComboBox_SelectionChanged_3"
  163. VerticalAlignment="Center"
  164. MinWidth="100"
  165. SelectedIndex="0"
  166. ItemsSource="{Binding PeoplePlaceList}">
  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="Price"
  179. Tag="1"
  180. Content="Сначала недорогие"
  181. IsChecked="True"
  182. Checked="RadioButton_Checked"
  183. VerticalAlignment="Center"/>
  184. <RadioButton
  185. GroupName="Price"
  186. Tag="2"
  187. Content="Сначала дорогие"
  188. Checked="RadioButton_Checked"
  189. VerticalAlignment="Center"/>
  190. <!-- минимальную высоту я тут поставил, чтобы верхнюю строку сетки было видно. В реальном приложении она не нужна -->
  191. </WrapPanel>
  192. </Grid>
  193. </Window>