|
- <Window x:Class="BPASmartClient.RecipeManagement.View.RecipesConfigure"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:local="clr-namespace:BPASmartClient.RecipeManagement.View"
- xmlns:vm="clr-namespace:BPASmart.RecipeManagement.ViewModel"
- mc:Ignorable="d"
- Title="RecipesConfigure" Height="600" Width="400" WindowStartupLocation="CenterScreen" WindowStyle="None" Background="White" MouseLeftButtonDown="Window_MouseLeftButtonDown">
- <Window.DataContext>
- <vm:RecipesConfigureViewModel/>
- </Window.DataContext>
- <Window.Resources>
-
-
- <Style x:Key="ComboBoxStyle" TargetType="{x:Type ComboBox}">
- <Setter Property="BorderThickness" Value="0" />
- <Setter Property="ItemContainerStyle">
- <Setter.Value>
- <Style TargetType="ComboBoxItem">
- <Setter Property="Height" Value="25" />
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type ComboBoxItem}">
- <Grid Width="{TemplateBinding Width}" Height="{TemplateBinding Height}">
- <Border x:Name="_borderbg" Background="White" />
-
- <TextBlock
- x:Name="_txt"
- Margin="5,0,3,0"
- FontWeight="Black"
- HorizontalAlignment="Left"
- VerticalAlignment="Center"
- Foreground="Black"
- Text="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}" />
-
- <Border
- x:Name="_border"
- Background="White"
- Opacity="0" />
- </Grid>
- <ControlTemplate.Triggers>
- <MultiTrigger>
- <MultiTrigger.Conditions>
- <Condition Property="IsSelected" Value="false" />
- <Condition Property="IsMouseOver" Value="true" />
- </MultiTrigger.Conditions>
- <Setter TargetName="_borderbg" Property="Background" Value="#AFEEEE" />
- <Setter TargetName="_txt" Property="Foreground" Value="black" />
- </MultiTrigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- </Setter.Value>
- </Setter>
-
-
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type ComboBox}">
- <Grid>
-
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="0.7*" />
- <ColumnDefinition Width="0.3*" MaxWidth="30" />
- </Grid.ColumnDefinitions>
- <Border
- x:Name="_prybr"
- Grid.Column="0"
- Grid.ColumnSpan="2"
- BorderBrush="{TemplateBinding BorderBrush}"
- BorderThickness="{TemplateBinding BorderThickness}"
- CornerRadius="0" />
- <ContentPresenter
- x:Name="ContentSite"
- Margin="3,3,0,3"
- HorizontalAlignment="Center"
- VerticalAlignment="Center"
- Content="{TemplateBinding SelectionBoxItem}"
- ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
- ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
- IsHitTestVisible="False" />
-
- <!-- ToggleButton 已数据绑定到 ComboBox 本身以切换 IsDropDownOpen -->
- <ToggleButton
- x:Name="ToggleButton"
- Grid.Column="0"
- Grid.ColumnSpan="2"
- ClickMode="Press"
- Focusable="false"
- IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
- Template="{StaticResource ComboBoxToggleButton}" />
- <!-- 必须将 TextBox 命名为 PART_EditableTextBox,否则 ComboBox 将无法识别它 -->
- <TextBox
- x:Name="PART_EditableTextBox"
- Margin="2,0,0,0"
- VerticalAlignment="Center"
- Background="Transparent"
- BorderThickness="0"
- CaretBrush="{TemplateBinding Foreground}"
- Focusable="True"
- Foreground="{TemplateBinding Foreground}"
- IsReadOnly="{TemplateBinding IsReadOnly}"
- Visibility="Hidden" />
-
- <!-- Popup 可显示 ComboBox 中的项列表。IsOpen 已数据绑定到通过 ComboBoxToggleButton 来切换的 IsDropDownOpen -->
- <Popup
- x:Name="Popup"
- AllowsTransparency="True"
- Focusable="False"
- IsOpen="{TemplateBinding IsDropDownOpen}"
- Placement="Bottom"
- PopupAnimation="Slide">
- <Grid
- x:Name="DropDown"
- MinWidth="{TemplateBinding ActualWidth}"
- MaxHeight="150"
- SnapsToDevicePixels="True">
- <Border
- x:Name="DropDownBorder"
- BorderBrush="Black"
- BorderThickness="0" />
- <ScrollViewer
- Margin="1"
- CanContentScroll="True"
- HorizontalScrollBarVisibility="Auto"
- SnapsToDevicePixels="True"
- VerticalScrollBarVisibility="Auto">
- <!-- StackPanel 用于显示子级,方法是将 IsItemsHost 设置为 True -->
- <!-- 一下可以设置列表背景色 -->
- <StackPanel
- Background="White"
- IsItemsHost="True"
- KeyboardNavigation.DirectionalNavigation="Contained" />
- </ScrollViewer>
- </Grid>
- </Popup>
- </Grid>
- <ControlTemplate.Triggers>
- <Trigger Property="IsEditable" Value="true">
- <Setter TargetName="PART_EditableTextBox" Property="Visibility" Value="Visible" />
- </Trigger>
- <Trigger Property="IsMouseOver" Value="True">
- <Setter TargetName="_prybr" Property="BorderBrush" Value="#aa3ba7f2" />
-
- </Trigger>
- <Trigger Property="IsEnabled" Value="False">
- <Setter TargetName="ContentSite" Property="Opacity" Value="0.6" />
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- </Window.Resources>
- <Grid>
- <Grid.RowDefinitions>
- <RowDefinition Height="50"/>
- <RowDefinition />
- <RowDefinition Height="30"/>
- <RowDefinition Height="60"/>
- </Grid.RowDefinitions>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="103*" />
- <ColumnDefinition Width="147*" />
- <ColumnDefinition Width="100*" />
- </Grid.ColumnDefinitions>
- <TextBlock Text="配方名称:" FontSize="22"
- HorizontalAlignment="Center" VerticalAlignment="Center" Height="28" Width="92"/>
- <TextBox Text="{Binding RecipeName}" FontSize="20" Grid.Column="1" Width="160" Height="36"
- VerticalAlignment="Center" HorizontalAlignment="Center"
- VerticalContentAlignment="Center"/>
- <Button Grid.Column="2"
- Content="添加原料"
- Foreground="White" FontSize="16" Width="90" Height="30" Margin="10" Background="#58B0ED"
- Command="{Binding AddMaterailsCommand}"/>
- <ScrollViewer Grid.ColumnSpan="3"
- Grid.Row="1"
- Margin="15,10"
- HorizontalScrollBarVisibility="Hidden"
- VerticalScrollBarVisibility="Auto">
- <ItemsControl ItemsSource="{Binding recipeMaterials}" >
- <ItemsControl.ItemTemplate>
- <DataTemplate>
- <RadioButton GroupName="all">
- <RadioButton.Template>
- <ControlTemplate TargetType="RadioButton">
- <Grid Name="gr" Height="40">
- <Grid.ColumnDefinitions>
- <ColumnDefinition />
- <ColumnDefinition />
- <ColumnDefinition Width="0.5*" />
- </Grid.ColumnDefinitions>
-
- <ComboBox
- Name="cb"
- Grid.Column="0"
- Margin="3,1"
- VerticalAlignment="Center"
- BorderBrush="Black"
- BorderThickness="1"
- FontFamily="楷体"
- FontSize="20"
- Foreground="Black"
- IsEditable="False"
- ItemsSource="{Binding DataContext.materialsName, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
- Style="{StaticResource ComboBoxStyle}"
- SelectedItem="{Binding Name}"
- />
-
-
- <StackPanel
- Grid.Column="1"
- VerticalAlignment="Center"
- Orientation="Horizontal">
- <TextBox
- Name="tb"
- Grid.Column="1"
- Width="100"
- Height="29"
- Margin="3,1"
- VerticalAlignment="Center"
- FontSize="20"
- Text="{Binding MaterialWeight}" />
-
- <TextBlock
- Grid.Column="1"
- Margin="0,0,8,4"
- HorizontalAlignment="Right"
- VerticalAlignment="Center"
- FontSize="20"
- Text="g" />
-
- </StackPanel>
-
- <Button
- Grid.Column="2"
- Width="70"
- Height="28"
- Margin="25,0,0,0"
- Foreground="White"
- FontSize="16"
- Background="#58B0ED"
- Command="{Binding DataContext.DeleteCommand, RelativeSource={RelativeSource AncestorType=Window, Mode=FindAncestor}}"
- CommandParameter="{Binding ID}"
- Content="删 除" />
-
- </Grid>
-
-
- </ControlTemplate>
- </RadioButton.Template>
- </RadioButton>
- </DataTemplate>
- </ItemsControl.ItemTemplate>
- </ItemsControl>
- </ScrollViewer>
-
- <TextBlock Text="{Binding ErrorMessage}" Grid.Row="2" Grid.ColumnSpan="3"
- Foreground="Red" VerticalAlignment="Center" HorizontalAlignment="Center"/>
- <StackPanel Grid.Row="4" Grid.ColumnSpan="3" Orientation="Horizontal"
- HorizontalAlignment="Center" VerticalAlignment="Center">
- <Button Content="保存" Foreground="White" FontSize="22" Width="120" Height="40" Margin="10" Background="#58B0ED"
- Command="{Binding SaveCommand}"/>
- <Button Content="取消" Foreground="White" FontSize="22" Width="120" Height="40" Margin="10" Background="#58B0ED"
- Click="Button_Click"/>
-
-
- </StackPanel>
- </Grid>
- </Window>
|