MainWindow.xaml 9.0 KB

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