终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

274 lines
15 KiB

  1. <Window x:Class="BPASmartClient.RecipeManagement.View.RecipesConfigure"
  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:BPASmartClient.RecipeManagement.View"
  7. xmlns:vm="clr-namespace:BPASmart.RecipeManagement.ViewModel"
  8. mc:Ignorable="d"
  9. Title="RecipesConfigure" Height="600" Width="400" WindowStartupLocation="CenterScreen" WindowStyle="None" Background="White" MouseLeftButtonDown="Window_MouseLeftButtonDown">
  10. <Window.DataContext>
  11. <vm:RecipesConfigureViewModel/>
  12. </Window.DataContext>
  13. <Window.Resources>
  14. <Style x:Key="ComboBoxStyle" TargetType="{x:Type ComboBox}">
  15. <Setter Property="BorderThickness" Value="0" />
  16. <Setter Property="ItemContainerStyle">
  17. <Setter.Value>
  18. <Style TargetType="ComboBoxItem">
  19. <Setter Property="Height" Value="25" />
  20. <Setter Property="Template">
  21. <Setter.Value>
  22. <ControlTemplate TargetType="{x:Type ComboBoxItem}">
  23. <Grid Width="{TemplateBinding Width}" Height="{TemplateBinding Height}">
  24. <Border x:Name="_borderbg" Background="White" />
  25. <TextBlock
  26. x:Name="_txt"
  27. Margin="5,0,3,0"
  28. FontWeight="Black"
  29. HorizontalAlignment="Left"
  30. VerticalAlignment="Center"
  31. Foreground="Black"
  32. Text="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}" />
  33. <Border
  34. x:Name="_border"
  35. Background="White"
  36. Opacity="0" />
  37. </Grid>
  38. <ControlTemplate.Triggers>
  39. <MultiTrigger>
  40. <MultiTrigger.Conditions>
  41. <Condition Property="IsSelected" Value="false" />
  42. <Condition Property="IsMouseOver" Value="true" />
  43. </MultiTrigger.Conditions>
  44. <Setter TargetName="_borderbg" Property="Background" Value="#AFEEEE" />
  45. <Setter TargetName="_txt" Property="Foreground" Value="black" />
  46. </MultiTrigger>
  47. </ControlTemplate.Triggers>
  48. </ControlTemplate>
  49. </Setter.Value>
  50. </Setter>
  51. </Style>
  52. </Setter.Value>
  53. </Setter>
  54. <Setter Property="Template">
  55. <Setter.Value>
  56. <ControlTemplate TargetType="{x:Type ComboBox}">
  57. <Grid>
  58. <Grid.ColumnDefinitions>
  59. <ColumnDefinition Width="0.7*" />
  60. <ColumnDefinition Width="0.3*" MaxWidth="30" />
  61. </Grid.ColumnDefinitions>
  62. <Border
  63. x:Name="_prybr"
  64. Grid.Column="0"
  65. Grid.ColumnSpan="2"
  66. BorderBrush="{TemplateBinding BorderBrush}"
  67. BorderThickness="{TemplateBinding BorderThickness}"
  68. CornerRadius="0" />
  69. <ContentPresenter
  70. x:Name="ContentSite"
  71. Margin="3,3,0,3"
  72. HorizontalAlignment="Center"
  73. VerticalAlignment="Center"
  74. Content="{TemplateBinding SelectionBoxItem}"
  75. ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
  76. ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
  77. IsHitTestVisible="False" />
  78. <!-- ToggleButton 已数据绑定到 ComboBox 本身以切换 IsDropDownOpen -->
  79. <ToggleButton
  80. x:Name="ToggleButton"
  81. Grid.Column="0"
  82. Grid.ColumnSpan="2"
  83. ClickMode="Press"
  84. Focusable="false"
  85. IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
  86. Template="{StaticResource ComboBoxToggleButton}" />
  87. <!-- 必须将 TextBox 命名为 PART_EditableTextBox,否则 ComboBox 将无法识别它 -->
  88. <TextBox
  89. x:Name="PART_EditableTextBox"
  90. Margin="2,0,0,0"
  91. VerticalAlignment="Center"
  92. Background="Transparent"
  93. BorderThickness="0"
  94. CaretBrush="{TemplateBinding Foreground}"
  95. Focusable="True"
  96. Foreground="{TemplateBinding Foreground}"
  97. IsReadOnly="{TemplateBinding IsReadOnly}"
  98. Visibility="Hidden" />
  99. <!-- Popup 可显示 ComboBox 中的项列表。IsOpen 已数据绑定到通过 ComboBoxToggleButton 来切换的 IsDropDownOpen -->
  100. <Popup
  101. x:Name="Popup"
  102. AllowsTransparency="True"
  103. Focusable="False"
  104. IsOpen="{TemplateBinding IsDropDownOpen}"
  105. Placement="Bottom"
  106. PopupAnimation="Slide">
  107. <Grid
  108. x:Name="DropDown"
  109. MinWidth="{TemplateBinding ActualWidth}"
  110. MaxHeight="150"
  111. SnapsToDevicePixels="True">
  112. <Border
  113. x:Name="DropDownBorder"
  114. BorderBrush="Black"
  115. BorderThickness="0" />
  116. <ScrollViewer
  117. Margin="1"
  118. CanContentScroll="True"
  119. HorizontalScrollBarVisibility="Auto"
  120. SnapsToDevicePixels="True"
  121. VerticalScrollBarVisibility="Auto">
  122. <!-- StackPanel 用于显示子级,方法是将 IsItemsHost 设置为 True -->
  123. <!-- 一下可以设置列表背景色 -->
  124. <StackPanel
  125. Background="White"
  126. IsItemsHost="True"
  127. KeyboardNavigation.DirectionalNavigation="Contained" />
  128. </ScrollViewer>
  129. </Grid>
  130. </Popup>
  131. </Grid>
  132. <ControlTemplate.Triggers>
  133. <Trigger Property="IsEditable" Value="true">
  134. <Setter TargetName="PART_EditableTextBox" Property="Visibility" Value="Visible" />
  135. </Trigger>
  136. <Trigger Property="IsMouseOver" Value="True">
  137. <Setter TargetName="_prybr" Property="BorderBrush" Value="#aa3ba7f2" />
  138. </Trigger>
  139. <Trigger Property="IsEnabled" Value="False">
  140. <Setter TargetName="ContentSite" Property="Opacity" Value="0.6" />
  141. </Trigger>
  142. </ControlTemplate.Triggers>
  143. </ControlTemplate>
  144. </Setter.Value>
  145. </Setter>
  146. </Style>
  147. </Window.Resources>
  148. <Grid>
  149. <Grid.RowDefinitions>
  150. <RowDefinition Height="50"/>
  151. <RowDefinition />
  152. <RowDefinition Height="30"/>
  153. <RowDefinition Height="60"/>
  154. </Grid.RowDefinitions>
  155. <Grid.ColumnDefinitions>
  156. <ColumnDefinition Width="103*" />
  157. <ColumnDefinition Width="147*" />
  158. <ColumnDefinition Width="100*" />
  159. </Grid.ColumnDefinitions>
  160. <TextBlock Text="配方名称:" FontSize="22"
  161. HorizontalAlignment="Center" VerticalAlignment="Center" Height="28" Width="92"/>
  162. <TextBox Text="{Binding RecipeName}" FontSize="20" Grid.Column="1" Width="160" Height="36"
  163. VerticalAlignment="Center" HorizontalAlignment="Center"
  164. VerticalContentAlignment="Center"/>
  165. <Button Grid.Column="2"
  166. Content="添加原料"
  167. Foreground="White" FontSize="16" Width="90" Height="30" Margin="10" Background="#58B0ED"
  168. Command="{Binding AddMaterailsCommand}"/>
  169. <ScrollViewer Grid.ColumnSpan="3"
  170. Grid.Row="1"
  171. Margin="15,10"
  172. HorizontalScrollBarVisibility="Hidden"
  173. VerticalScrollBarVisibility="Auto">
  174. <ItemsControl ItemsSource="{Binding recipeMaterials}" >
  175. <ItemsControl.ItemTemplate>
  176. <DataTemplate>
  177. <RadioButton GroupName="all">
  178. <RadioButton.Template>
  179. <ControlTemplate TargetType="RadioButton">
  180. <Grid Name="gr" Height="40">
  181. <Grid.ColumnDefinitions>
  182. <ColumnDefinition />
  183. <ColumnDefinition />
  184. <ColumnDefinition Width="0.5*" />
  185. </Grid.ColumnDefinitions>
  186. <ComboBox
  187. Name="cb"
  188. Grid.Column="0"
  189. Margin="3,1"
  190. VerticalAlignment="Center"
  191. BorderBrush="Black"
  192. BorderThickness="1"
  193. FontFamily="楷体"
  194. FontSize="20"
  195. Foreground="Black"
  196. IsEditable="False"
  197. ItemsSource="{Binding DataContext.materialsName, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
  198. Style="{StaticResource ComboBoxStyle}"
  199. SelectedItem="{Binding Name}"
  200. />
  201. <StackPanel
  202. Grid.Column="1"
  203. VerticalAlignment="Center"
  204. Orientation="Horizontal">
  205. <TextBox
  206. Name="tb"
  207. Grid.Column="1"
  208. Width="100"
  209. Height="29"
  210. Margin="3,1"
  211. VerticalAlignment="Center"
  212. FontSize="20"
  213. Text="{Binding MaterialWeight}" />
  214. <TextBlock
  215. Grid.Column="1"
  216. Margin="0,0,8,4"
  217. HorizontalAlignment="Right"
  218. VerticalAlignment="Center"
  219. FontSize="20"
  220. Text="g" />
  221. </StackPanel>
  222. <Button
  223. Grid.Column="2"
  224. Width="70"
  225. Height="28"
  226. Margin="25,0,0,0"
  227. Foreground="White"
  228. FontSize="16"
  229. Background="#58B0ED"
  230. Command="{Binding DataContext.DeleteCommand, RelativeSource={RelativeSource AncestorType=Window, Mode=FindAncestor}}"
  231. CommandParameter="{Binding ID}"
  232. Content="删 除" />
  233. </Grid>
  234. </ControlTemplate>
  235. </RadioButton.Template>
  236. </RadioButton>
  237. </DataTemplate>
  238. </ItemsControl.ItemTemplate>
  239. </ItemsControl>
  240. </ScrollViewer>
  241. <TextBlock Text="{Binding ErrorMessage}" Grid.Row="2" Grid.ColumnSpan="3"
  242. Foreground="Red" VerticalAlignment="Center" HorizontalAlignment="Center"/>
  243. <StackPanel Grid.Row="4" Grid.ColumnSpan="3" Orientation="Horizontal"
  244. HorizontalAlignment="Center" VerticalAlignment="Center">
  245. <Button Content="保存" Foreground="White" FontSize="22" Width="120" Height="40" Margin="10" Background="#58B0ED"
  246. Command="{Binding SaveCommand}"/>
  247. <Button Content="取消" Foreground="White" FontSize="22" Width="120" Height="40" Margin="10" Background="#58B0ED"
  248. Click="Button_Click"/>
  249. </StackPanel>
  250. </Grid>
  251. </Window>