优化更新代码,添加界面功能并整合
This commit is contained in:
294
WPFluent/Controls/ToolBar/ToolBar.xaml
Normal file
294
WPFluent/Controls/ToolBar/ToolBar.xaml
Normal file
@@ -0,0 +1,294 @@
|
||||
<!--
|
||||
This Source Code Form is subject to the terms of the MIT License.
|
||||
If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
|
||||
Copyright (C) Leszek Pomianowski and WPF UI Contributors.
|
||||
All Rights Reserved.
|
||||
-->
|
||||
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="clr-namespace:WPFluent.Controls">
|
||||
|
||||
<Style x:Key="ToolBarButtonBaseStyle" TargetType="{x:Type ButtonBase}">
|
||||
<Setter Property="Background">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush Opacity="0.0" Color="{DynamicResource ControlFillColorDefault}" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="Cursor" Value="Hand" />
|
||||
<Setter Property="SnapsToDevicePixels" Value="True" />
|
||||
<Setter Property="OverridesDefaultStyle" Value="True" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ButtonBase}">
|
||||
<Border
|
||||
x:Name="Border"
|
||||
Padding="12,6"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}">
|
||||
<ContentPresenter
|
||||
Margin="2"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
RecognizesAccessKey="True" />
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Trigger.EnterActions>
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation
|
||||
Storyboard.TargetName="Border"
|
||||
Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Opacity)"
|
||||
From="0.0"
|
||||
To="1.0"
|
||||
Duration="0:0:0.16" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</Trigger.EnterActions>
|
||||
<Trigger.ExitActions>
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation
|
||||
Storyboard.TargetName="Border"
|
||||
Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Opacity)"
|
||||
From="1.0"
|
||||
To="0.0"
|
||||
Duration="0:0:0.16" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</Trigger.ExitActions>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style
|
||||
x:Key="{x:Static ToolBar.ButtonStyleKey}"
|
||||
BasedOn="{StaticResource ToolBarButtonBaseStyle}"
|
||||
TargetType="{x:Type Button}" />
|
||||
<Style
|
||||
x:Key="{x:Static ToolBar.ToggleButtonStyleKey}"
|
||||
BasedOn="{StaticResource ToolBarButtonBaseStyle}"
|
||||
TargetType="{x:Type ToggleButton}" />
|
||||
<Style
|
||||
x:Key="{x:Static ToolBar.CheckBoxStyleKey}"
|
||||
BasedOn="{StaticResource ToolBarButtonBaseStyle}"
|
||||
TargetType="{x:Type CheckBox}" />
|
||||
<Style
|
||||
x:Key="{x:Static ToolBar.RadioButtonStyleKey}"
|
||||
BasedOn="{StaticResource ToolBarButtonBaseStyle}"
|
||||
TargetType="{x:Type RadioButton}" />
|
||||
|
||||
<Style x:Key="{x:Static ToolBar.TextBoxStyleKey}" TargetType="{x:Type TextBox}">
|
||||
<Setter Property="KeyboardNavigation.TabNavigation" Value="None" />
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
|
||||
<Setter Property="AllowDrop" Value="True" />
|
||||
<Setter Property="SnapsToDevicePixels" Value="True" />
|
||||
<Setter Property="OverridesDefaultStyle" Value="True" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type TextBox}">
|
||||
<Border
|
||||
x:Name="Border"
|
||||
Padding="2"
|
||||
Background="Transparent"
|
||||
BorderBrush="Transparent"
|
||||
BorderThickness="0">
|
||||
<controls:PassiveScrollViewer x:Name="PART_ContentHost" Margin="0" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ToolBarThumbStyle" TargetType="{x:Type Thumb}">
|
||||
<Setter Property="SnapsToDevicePixels" Value="True" />
|
||||
<Setter Property="OverridesDefaultStyle" Value="True" />
|
||||
<Setter Property="Cursor" Value="SizeAll" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Thumb}">
|
||||
<Border Background="Transparent" SnapsToDevicePixels="True">
|
||||
<Rectangle Margin="0,2">
|
||||
<Rectangle.Fill>
|
||||
<DrawingBrush
|
||||
TileMode="Tile"
|
||||
Viewbox="0,0,8,8"
|
||||
ViewboxUnits="Absolute"
|
||||
Viewport="0,0,4,4"
|
||||
ViewportUnits="Absolute">
|
||||
<DrawingBrush.Drawing>
|
||||
<DrawingGroup>
|
||||
<GeometryDrawing Brush="#AAA" Geometry="M 4 4 L 4 8 L 8 8 L 8 4 z" />
|
||||
</DrawingGroup>
|
||||
</DrawingBrush.Drawing>
|
||||
</DrawingBrush>
|
||||
</Rectangle.Fill>
|
||||
</Rectangle>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ToolBarOverflowButtonStyle" TargetType="{x:Type ToggleButton}">
|
||||
<Setter Property="Foreground">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush Color="{DynamicResource TextFillColorTertiary}" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="Cursor" Value="Hand" />
|
||||
<Setter Property="SnapsToDevicePixels" Value="True" />
|
||||
<Setter Property="OverridesDefaultStyle" Value="True" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ToggleButton}">
|
||||
<Border
|
||||
x:Name="Border"
|
||||
Background="{TemplateBinding Background}"
|
||||
CornerRadius="0,3,3,0"
|
||||
SnapsToDevicePixels="true">
|
||||
<Grid>
|
||||
<controls:SymbolIcon
|
||||
Margin="0"
|
||||
VerticalAlignment="Bottom"
|
||||
Foreground="{TemplateBinding Foreground}"
|
||||
Symbol="ChevronDown20" />
|
||||
<ContentPresenter />
|
||||
</Grid>
|
||||
<!--
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="CommonStates">
|
||||
<VisualState x:Name="Normal" />
|
||||
<VisualState x:Name="Pressed">
|
||||
<Storyboard>
|
||||
<ColorAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="(Panel.Background). (GradientBrush.GradientStops)[1].(GradientStop.Color)">
|
||||
<EasingColorKeyFrame KeyTime="0" Value="{StaticResource ControlPressedColor}" />
|
||||
</ColorAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="MouseOver">
|
||||
<Storyboard>
|
||||
<ColorAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="(Panel.Background). (GradientBrush.GradientStops)[1].(GradientStop.Color)">
|
||||
<EasingColorKeyFrame KeyTime="0" Value="{StaticResource ControlMouseOverColor}" />
|
||||
</ColorAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Disabled">
|
||||
<Storyboard>
|
||||
<ColorAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="(Panel.Background). (GradientBrush.GradientStops)[1].(GradientStop.Color)">
|
||||
<EasingColorKeyFrame KeyTime="0" Value="{StaticResource DisabledBorderLightColor}" />
|
||||
</ColorAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
-->
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Width" Value="0" />
|
||||
</Trigger>
|
||||
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="{x:Type ToolBar}" TargetType="{x:Type ToolBar}">
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="SnapsToDevicePixels" Value="True" />
|
||||
<Setter Property="OverridesDefaultStyle" Value="True" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ToolBar}">
|
||||
<Border
|
||||
x:Name="Border"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="4">
|
||||
<DockPanel>
|
||||
<ToggleButton
|
||||
ClickMode="Press"
|
||||
DockPanel.Dock="Right"
|
||||
IsChecked="{Binding IsOverflowOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
IsEnabled="{TemplateBinding HasOverflowItems}"
|
||||
Style="{StaticResource ToolBarOverflowButtonStyle}">
|
||||
<Popup
|
||||
x:Name="OverflowPopup"
|
||||
AllowsTransparency="True"
|
||||
Focusable="False"
|
||||
IsOpen="{Binding IsOverflowOpen, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
Placement="Bottom"
|
||||
PopupAnimation="Slide"
|
||||
StaysOpen="False">
|
||||
<Border
|
||||
x:Name="DropDownBorder"
|
||||
Margin="12,0,12,18"
|
||||
Padding="0,3,0,3"
|
||||
BorderBrush="{DynamicResource MenuBorderColorDefaultBrush}"
|
||||
BorderThickness="1"
|
||||
CornerRadius="8"
|
||||
SnapsToDevicePixels="True">
|
||||
<Border.Background>
|
||||
<SolidColorBrush Color="{DynamicResource SystemFillColorSolidNeutralBackground}" />
|
||||
</Border.Background>
|
||||
|
||||
<ToolBarOverflowPanel
|
||||
x:Name="PART_ToolBarOverflowPanel"
|
||||
Margin="0"
|
||||
FocusVisualStyle="{x:Null}"
|
||||
Focusable="True"
|
||||
KeyboardNavigation.DirectionalNavigation="Cycle"
|
||||
KeyboardNavigation.TabNavigation="Cycle"
|
||||
WrapWidth="200" />
|
||||
</Border>
|
||||
</Popup>
|
||||
</ToggleButton>
|
||||
|
||||
<Thumb
|
||||
x:Name="ToolBarThumb"
|
||||
Width="10"
|
||||
Style="{StaticResource ToolBarThumbStyle}" />
|
||||
<ToolBarPanel
|
||||
x:Name="PART_ToolBarPanel"
|
||||
Margin="0,1,2,2"
|
||||
IsItemsHost="True" />
|
||||
</DockPanel>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsOverflowOpen" Value="true">
|
||||
<Setter TargetName="ToolBarThumb" Property="IsEnabled" Value="false" />
|
||||
</Trigger>
|
||||
<Trigger Property="ToolBarTray.IsLocked" Value="true">
|
||||
<Setter TargetName="ToolBarThumb" Property="Visibility" Value="Collapsed" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="{x:Type ToolBarTray}" TargetType="{x:Type ToolBarTray}">
|
||||
<Setter Property="Background">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush Color="{DynamicResource ControlFillColorDefault}" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Margin" Value="0" />
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
Reference in New Issue
Block a user