MainWindow.xaml 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. <Window x:Class="WpfAppA.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:WpfAppA"
  7. mc:Ignorable="d"
  8. Title="MainWindow" Height="450" Width="850">
  9. <Window.Resources>
  10. <Style
  11. x:Key="StackStyle"
  12. TargetType="ListBox"
  13. >
  14. <Setter
  15. Property="ItemsPanel"
  16. >
  17. <Setter.Value>
  18. <ItemsPanelTemplate>
  19. <StackPanel
  20. Orientation="Vertical"/>
  21. </ItemsPanelTemplate>
  22. </Setter.Value>
  23. </Setter>
  24. <Setter
  25. Property="ItemTemplate"
  26. >
  27. <Setter.Value>
  28. <DataTemplate>
  29. <Border
  30. BorderThickness="2"
  31. BorderBrush="DarkRed"
  32. CornerRadius="4"
  33. Margin="4"
  34. >
  35. <Grid>
  36. <Grid.ColumnDefinitions>
  37. <ColumnDefinition Width="64"/>
  38. <ColumnDefinition Width="*"/>
  39. <ColumnDefinition Width="auto"/>
  40. </Grid.ColumnDefinitions>
  41. <Image
  42. Width="64"
  43. Height="64"
  44. Source="{Binding ImageBitmap}"/>
  45. <StackPanel
  46. Grid.Column="1"
  47. Orientation="Vertical"
  48. Margin="5,2,0,5"
  49. >
  50. <TextBlock Text="{Binding name}"/>
  51. <TextBlock Text="{Binding surname}"/>
  52. </StackPanel>
  53. <TextBlock
  54. Grid.Column="2"
  55. Text="{Binding age}"
  56. Margin="0,2,10,0"/>
  57. </Grid>
  58. </Border>
  59. </DataTemplate>
  60. </Setter.Value>
  61. </Setter>
  62. </Style>
  63. <Style
  64. x:Key="WrapStyle"
  65. TargetType="ListBox"
  66. >
  67. <Setter
  68. Property="ItemsPanel"
  69. >
  70. <Setter.Value>
  71. <ItemsPanelTemplate>
  72. <WrapPanel
  73. HorizontalAlignment="Center"
  74. ItemWidth="200"/>
  75. </ItemsPanelTemplate>
  76. </Setter.Value>
  77. </Setter>
  78. <Setter
  79. Property="ItemTemplate"
  80. >
  81. <Setter.Value>
  82. <DataTemplate>
  83. <Border
  84. BorderThickness="1"
  85. BorderBrush="Black"
  86. CornerRadius="5"
  87. Margin="5"
  88. >
  89. <StackPanel
  90. Orientation="Vertical"
  91. >
  92. <Image
  93. Width="200"
  94. Source="{Binding ImageBitmap}"/>
  95. <TextBlock
  96. Text="{Binding name}"
  97. HorizontalAlignment="Center"/>
  98. <TextBlock
  99. Text="{Binding surname}"
  100. HorizontalAlignment="Center"/>
  101. <TextBlock
  102. Text="{Binding age}"
  103. HorizontalAlignment="Center"/>
  104. </StackPanel>
  105. </Border>
  106. </DataTemplate>
  107. </Setter.Value>
  108. </Setter>
  109. </Style>
  110. </Window.Resources>
  111. <Grid
  112. ShowGridLines="True">
  113. <Grid.RowDefinitions>
  114. <RowDefinition Height="auto"/>
  115. <RowDefinition />
  116. <RowDefinition Height="auto"/>
  117. </Grid.RowDefinitions>
  118. <Grid.ColumnDefinitions>
  119. <ColumnDefinition Width="200"/>
  120. <ColumnDefinition/>
  121. </Grid.ColumnDefinitions>
  122. <!-- типа логотип компании -->
  123. <Image
  124. Source="./bin\Debug\net8.0-windows\img\portrait.jpg"
  125. Grid.RowSpan="2" HorizontalAlignment="Right"/>
  126. <ListBox
  127. x:Name="HeroListBox"
  128. Style="{StaticResource StackStyle}"
  129. Grid.Column="1"
  130. Grid.Row="1"
  131. Background="White"
  132. ItemsSource="{Binding HeroList}" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
  133. <ListBox.ItemContainerStyle>
  134. <Style
  135. TargetType="ListBoxItem">
  136. <Setter
  137. Property="HorizontalContentAlignment"
  138. Value="Stretch" />
  139. </Style>
  140. </ListBox.ItemContainerStyle>
  141. <DataTemplate>
  142. <Border
  143. BorderThickness="1"
  144. BorderBrush="Black"
  145. CornerRadius="5">
  146. <Grid
  147. Width="200"
  148. Margin="10"
  149. HorizontalAlignment="Stretch">
  150. <Grid.ColumnDefinitions>
  151. <ColumnDefinition Width="64"/>
  152. <ColumnDefinition Width="*"/>
  153. <ColumnDefinition Width="auto"/>
  154. </Grid.ColumnDefinitions>
  155. <!-- сюда потом вставить колонки -->
  156. <StackPanel
  157. Grid.Column="1"
  158. Margin="5"
  159. Orientation="Vertical">
  160. <TextBlock
  161. Text="{Binding name}"/>
  162. <TextBlock
  163. Text="{Binding race}"/>
  164. <TextBlock
  165. Grid.Column="2"
  166. Text="{Binding Age}"/>
  167. </StackPanel>
  168. <Image
  169. Width="64"
  170. Height="64"
  171. Source="{Binding ImageBitmap}" />
  172. </Grid>
  173. </Border>
  174. </DataTemplate>
  175. </ListBox.ItemTemplate>
  176. </ListBox>
  177. <StackPanel
  178. x:Name="buttonsStack"
  179. Background="Black" >
  180. <Button
  181. x:Name="button1"
  182. Content="Кнопка 1" />
  183. <Button
  184. x:Name="button2"
  185. Content="Кнопка 2"
  186. Style="{x:Null}" />
  187. </StackPanel>
  188. <WrapPanel
  189. Orientation="Horizontal"
  190. Grid.Column="1"
  191. MinHeight="50">
  192. <Button
  193. Content="Переключить вид"
  194. Click="ToggleView_Click"/>
  195. <Label
  196. Content="Возраст:"
  197. VerticalAlignment="Center"/>
  198. <RadioButton
  199. GroupName="Age"
  200. Tag="1"
  201. Content="по возрастанию"
  202. IsChecked="True"
  203. Checked="RadioButton_Checked"
  204. VerticalAlignment="Center"/>
  205. <RadioButton
  206. GroupName="Age"
  207. Tag="2"
  208. Content="по убыванию "
  209. Checked="RadioButton_Checked"
  210. VerticalAlignment="Center"/>
  211. <Label
  212. Content="Искать:"
  213. VerticalAlignment="Center"/>
  214. <TextBox
  215. Width="200"
  216. VerticalAlignment="Center"
  217. x:Name="SearchFilterTextBox"
  218. KeyUp="SearchFilter_KeyUp"/>
  219. <Label
  220. Content="Мощь:"
  221. VerticalAlignment="Center"/>
  222. <ComboBox
  223. Name="powerFilterComboBox"
  224. SelectionChanged="powerFilterComboBox_SelectionChanged_1"
  225. VerticalAlignment="Center"
  226. MinWidth="100"
  227. SelectedIndex="0"
  228. ItemsSource="{Binding HeroPowerList}">
  229. <ComboBox.ItemTemplate>
  230. <DataTemplate>
  231. <Label
  232. Content="{Binding title}"/>
  233. </DataTemplate>
  234. </ComboBox.ItemTemplate>
  235. </ComboBox>
  236. <Label
  237. Content="Возраст:"
  238. VerticalAlignment="Center"/>
  239. <ComboBox
  240. Name="AgeFilterComboBox"
  241. SelectionChanged="AgeFilterComboBox_SelectionChanged_2"
  242. VerticalAlignment="Center"
  243. MinWidth="100"
  244. SelectedIndex="0"
  245. ItemsSource="{Binding HeroAgeList}">
  246. <ComboBox.ItemTemplate>
  247. <DataTemplate>
  248. <Label
  249. Content="{Binding title}"/>
  250. </DataTemplate>
  251. </ComboBox.ItemTemplate>
  252. </ComboBox>
  253. <Label
  254. Content="Раса:"
  255. VerticalAlignment="Center"/>
  256. <ComboBox
  257. Name="RaceFilterComboBox"
  258. SelectionChanged="RaceFilterComboBox_SelectionChanged_3"
  259. VerticalAlignment="Center"
  260. MinWidth="100"
  261. SelectedIndex="0"
  262. ItemsSource="{Binding HeroRaceList}">
  263. <ComboBox.ItemTemplate>
  264. <DataTemplate>
  265. <Label
  266. Content="{Binding title}"/>
  267. </DataTemplate>
  268. </ComboBox.ItemTemplate>
  269. </ComboBox>
  270. <!-- минимальную высоту я тут поставил, чтобы верхнюю строку сетки было видно. В реальном приложении она не нужна -->
  271. </WrapPanel>
  272. </Grid>
  273. </Window>