|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- <Application x:Class="BPASmart.RecipeManagement.App"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:local="clr-namespace:BPASmart.RecipeManagement"
- StartupUri="MainWindow.xaml">
- <Application.Resources>
- <Style TargetType="{x:Type ContextMenu}">
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type ContextMenu}">
- <Border x:Name="Border" CornerRadius="4" Background="#009ACD" BorderThickness="1" Margin="0">
- <Border.BorderBrush>
- <SolidColorBrush Color="#104E8B" />
- </Border.BorderBrush>
- <ItemsPresenter/>
- </Border>
- <ControlTemplate.Triggers>
- <MultiTrigger>
- <MultiTrigger.Conditions>
- <Condition Property="IsMouseOver" Value="True"/>
- </MultiTrigger.Conditions>
- <MultiTrigger.EnterActions>
- <BeginStoryboard>
- <Storyboard>
- <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(FrameworkElement.Width)">
- <SplineDoubleKeyFrame KeyTime="00:00:00.0020000" Value="0"/>
- <SplineDoubleKeyFrame KeyTime="00:00:00.20000" Value="110"/>
- </DoubleAnimationUsingKeyFrames>
- <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(FrameworkElement.Height)">
- <SplineDoubleKeyFrame KeyTime="00:00:00.0020000" Value="0"/>
- <SplineDoubleKeyFrame KeyTime="00:00:00.20000" Value="100"/>
- </DoubleAnimationUsingKeyFrames>
- </Storyboard>
- </BeginStoryboard>
- </MultiTrigger.EnterActions>
- </MultiTrigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- <Style TargetType="{x:Type MenuItem}">
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type MenuItem}">
- <Border Margin="0,5" MinWidth="80" CornerRadius="5">
- <Border.Background>
- <SolidColorBrush x:Name="MyAnimatedBrushBackground" Color="Transparent" />
- </Border.Background>
- <StackPanel Orientation="Horizontal">
- <TextBlock Text=" "/>
- <ContentPresenter ContentSource="Icon" HorizontalAlignment="Center" VerticalAlignment="Center" />
- <TextBlock Text=" "/>
- <ContentPresenter ContentSource="Header" HorizontalAlignment="Center" VerticalAlignment="Center"/>
- </StackPanel>
- </Border>
- <ControlTemplate.Triggers>
- <MultiTrigger>
- <MultiTrigger.Conditions>
- <Condition Property="IsMouseOver" Value="True"/>
- </MultiTrigger.Conditions>
- <MultiTrigger.EnterActions>
- <BeginStoryboard>
- <Storyboard>
- <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="MyAnimatedBrushBackground" Storyboard.TargetProperty="Color">
- <LinearColorKeyFrame Value="Transparent" KeyTime="00:00:00.0020000" />
- <LinearColorKeyFrame Value="#B0E2FF" KeyTime="00:00:00.0320000" />
- </ColorAnimationUsingKeyFrames>
- </Storyboard>
- </BeginStoryboard>
- </MultiTrigger.EnterActions>
- <MultiTrigger.ExitActions>
- <BeginStoryboard>
- <Storyboard>
- <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="MyAnimatedBrushBackground" Storyboard.TargetProperty="Color">
- <LinearColorKeyFrame Value="#7E9C9C9C" KeyTime="00:00:00.0020000" />
- <LinearColorKeyFrame Value="Transparent" KeyTime="00:00:00.0320000" />
- </ColorAnimationUsingKeyFrames>
- </Storyboard>
- </BeginStoryboard>
- </MultiTrigger.ExitActions>
- </MultiTrigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
-
-
- <ControlTemplate x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
- <Grid Height="25" HorizontalAlignment="Stretch" Background="Transparent">
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="*" />
- <ColumnDefinition Width="30" />
- </Grid.ColumnDefinitions>
- <Border
- Grid.ColumnSpan="2"
- Background="White"
- Opacity="0" />
-
- <Path
- x:Name="Arrow"
- Grid.Column="1"
- HorizontalAlignment="Center"
- VerticalAlignment="Center"
- Data="M 0 0 6 6 12 0 Z"
- Fill="Black"
- Stretch="None">
- <Path.Effect>
- <DropShadowEffect
- BlurRadius="10"
- Direction="90"
- Opacity="1"
- RenderingBias="Quality"
- ShadowDepth="0"
- Color="Transparent" />
- </Path.Effect>
- </Path>
- </Grid>
- <ControlTemplate.Triggers>
- <Trigger Property="IsChecked" Value="true">
- <Setter TargetName="Arrow" Property="RenderTransform">
- <Setter.Value>
- <RotateTransform Angle="180" CenterX="6" CenterY="3" />
- </Setter.Value>
- </Setter>
- <Setter TargetName="Arrow" Property="Margin" Value="0,0,0,2" />
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
-
- <Style TargetType="{x:Type ComboBox}">
- <Setter Property="BorderThickness" Value="1" />
- <Setter Property="Background" Value="White"/>
- <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="White"
- 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>
- </Application.Resources>
- </Application>
|