MainWindow.xaml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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. MouseDoubleClick="PeopleListBox_MouseDoubleClick"
  62. x:Name="PeopleListBox">
  63. <ListBox.ItemsPanel>
  64. <ItemsPanelTemplate>
  65. <WrapPanel
  66. HorizontalAlignment="Center" />
  67. </ItemsPanelTemplate>
  68. </ListBox.ItemsPanel>
  69. <ListBox.ItemTemplate>
  70. <DataTemplate>
  71. <Border
  72. BorderThickness="1"
  73. BorderBrush="Black"
  74. CornerRadius="5">
  75. <Grid Width="200"
  76. Margin="10"
  77. HorizontalAlignment="Stretch">
  78. <Grid.ColumnDefinitions>
  79. <ColumnDefinition Width="64"/>
  80. <ColumnDefinition Width="*"/>
  81. <ColumnDefinition Width="auto"/>
  82. </Grid.ColumnDefinitions>
  83. <Image
  84. Width="64"
  85. Height="64"
  86. Source="{Binding ImageBitmap,TargetNullValue={StaticResource defaultImage}}" />
  87. <StackPanel
  88. Grid.Column="1"
  89. Margin="5"
  90. Orientation="Vertical">
  91. <TextBlock
  92. Text="{Binding Name}"/>
  93. <TextBlock
  94. Text="{Binding Price}"/>
  95. <TextBlock
  96. Text="{Binding Place}"/>
  97. </StackPanel>
  98. <TextBlock
  99. Grid.Column="2"
  100. Text="{Binding Age}"/>
  101. </Grid>
  102. </Border>
  103. </DataTemplate>
  104. </ListBox.ItemTemplate>
  105. </ListBox>
  106. <StackPanel
  107. Orientation="Vertical"
  108. Grid.RowSpan="3"
  109. VerticalAlignment="Bottom">
  110. <Button
  111. x:Name="ExitButton"
  112. Content="Выход"
  113. Click="ExitButton_Click"
  114. Height="50"/>
  115. </StackPanel>
  116. <WrapPanel
  117. Orientation="Horizontal"
  118. Grid.Column="1"
  119. MinHeight="50">
  120. <Label
  121. Content="искать"
  122. VerticalAlignment="Center"/>
  123. <TextBox
  124. Width="200"
  125. VerticalAlignment="Center"
  126. x:Name="SearchFilterTextBox"
  127. KeyUp="SearchFilter_KeyUp"/>
  128. <ComboBox
  129. Name="GenderFilterComboBox"
  130. SelectionChanged="GenderFilterComboBox_SelectionChanged_1"
  131. VerticalAlignment="Center"
  132. MinWidth="100"
  133. SelectedIndex="0"
  134. ItemsSource="{Binding PeopleGenderList}">
  135. <ComboBox.ItemTemplate>
  136. <DataTemplate>
  137. <Label
  138. Content="{Binding title}"/>
  139. </DataTemplate>
  140. </ComboBox.ItemTemplate>
  141. </ComboBox>
  142. <Label
  143. Content="Возраст:"
  144. VerticalAlignment="Center"/>
  145. <ComboBox
  146. Name="AgeFilterComboBox"
  147. SelectionChanged="AgeFilterComboBox_SelectionChanged_2"
  148. VerticalAlignment="Center"
  149. MinWidth="100"
  150. SelectedIndex="0"
  151. ItemsSource="{Binding PeopleAgeList}">
  152. <ComboBox.ItemTemplate>
  153. <DataTemplate>
  154. <Label
  155. Content="{Binding title}"/>
  156. </DataTemplate>
  157. </ComboBox.ItemTemplate>
  158. </ComboBox>
  159. <Label
  160. Content="Место:"
  161. VerticalAlignment="Center"/>
  162. <ComboBox
  163. Name="PlaceFilterComboBox"
  164. SelectionChanged="PlaceFilterComboBox_SelectionChanged_3"
  165. VerticalAlignment="Center"
  166. MinWidth="100"
  167. SelectedIndex="0"
  168. ItemsSource="{Binding PeoplePlaceList}">
  169. <ComboBox.ItemTemplate>
  170. <DataTemplate>
  171. <Label
  172. Content="{Binding title}"/>
  173. </DataTemplate>
  174. </ComboBox.ItemTemplate>
  175. </ComboBox>
  176. <Label
  177. Content="Цена:"
  178. VerticalAlignment="Center"/>
  179. <RadioButton
  180. GroupName="Price"
  181. Tag="1"
  182. Content="Сначала недорогие"
  183. IsChecked="True"
  184. Checked="RadioButton_Checked"
  185. VerticalAlignment="Center"/>
  186. <RadioButton
  187. GroupName="Price"
  188. Tag="2"
  189. Content="Сначала дорогие"
  190. Checked="RadioButton_Checked"
  191. VerticalAlignment="Center"/>
  192. <!-- минимальную высоту я тут поставил, чтобы верхнюю строку сетки было видно. В реальном приложении она не нужна -->
  193. </WrapPanel>
  194. </Grid>
  195. </Window>