mirror of
https://gitee.com/handyorg/HandyControl.git
synced 2024-11-29 18:38:30 +08:00
add Expander
This commit is contained in:
parent
53603b4648
commit
c9fdcd1114
@ -1,6 +1,7 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
public class IconElement : DependencyObject
|
||||
@ -31,5 +32,4 @@ namespace HandyControl.Controls
|
||||
return (double)element.GetValue(AngleProperty);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
35
HandyControl/Controls/Attach/IconSwitchElement.cs
Normal file
35
HandyControl/Controls/Attach/IconSwitchElement.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
public class IconSwitchElement : DependencyObject
|
||||
{
|
||||
public static readonly DependencyProperty GeometryProperty = DependencyProperty.RegisterAttached(
|
||||
"Geometry", typeof(Geometry), typeof(IconSwitchElement), new PropertyMetadata(default(Geometry)));
|
||||
|
||||
public static void SetGeometry(DependencyObject element, Geometry value)
|
||||
{
|
||||
element.SetValue(GeometryProperty, value);
|
||||
}
|
||||
|
||||
public static Geometry GetGeometry(DependencyObject element)
|
||||
{
|
||||
return (Geometry)element.GetValue(GeometryProperty);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty GeometrySelectedProperty = DependencyProperty.RegisterAttached(
|
||||
"GeometrySelected", typeof(Geometry), typeof(IconSwitchElement), new PropertyMetadata(default(Geometry)));
|
||||
|
||||
public static void SetGeometrySelected(DependencyObject element, Geometry value)
|
||||
{
|
||||
element.SetValue(GeometrySelectedProperty, value);
|
||||
}
|
||||
|
||||
public static Geometry GetGeometrySelected(DependencyObject element)
|
||||
{
|
||||
return (Geometry)element.GetValue(GeometrySelectedProperty);
|
||||
}
|
||||
}
|
||||
}
|
15
HandyControl/Controls/Attach/StatusSwitchElement.cs
Normal file
15
HandyControl/Controls/Attach/StatusSwitchElement.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System.Windows;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
public class StatusSwitchElement
|
||||
{
|
||||
public static readonly DependencyProperty CheckedElementProperty = DependencyProperty.RegisterAttached(
|
||||
"CheckedElement", typeof(object), typeof(StatusSwitchElement), new PropertyMetadata(default(object)));
|
||||
|
||||
public static void SetCheckedElement(DependencyObject element, object value) => element.SetValue(CheckedElementProperty, value);
|
||||
|
||||
public static object GetCheckedElement(DependencyObject element) => element.GetValue(CheckedElementProperty);
|
||||
}
|
||||
}
|
@ -31,13 +31,15 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Controls\Attach\IconSwitchElement.cs" />
|
||||
<Compile Include="Controls\Attach\StatusSwitchElement.cs" />
|
||||
<Compile Include="Controls\Carousel.xaml.cs">
|
||||
<DependentUpon>Carousel.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Controls\ColorPicker.xaml.cs">
|
||||
<DependentUpon>ColorPicker.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Controls\IconElement.cs" />
|
||||
<Compile Include="Controls\Attach\IconElement.cs" />
|
||||
<Compile Include="Controls\Info\InfoControl.cs" />
|
||||
<Compile Include="Controls\Info\InfoNumericUpDown.xaml.cs">
|
||||
<DependentUpon>InfoNumericUpDown.xaml</DependentUpon>
|
||||
@ -200,6 +202,14 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Styles\Base\ToggleButtonBaseStyle.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Styles\Base\ToggleButtonSwitchBaseStyle.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Styles\Border.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@ -208,6 +218,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Styles\Expander.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Styles\ListBox.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@ -244,6 +258,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Styles\ToggleButton.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="PresentationCore" />
|
||||
|
49
HandyControl/Themes/Styles/Base/ToggleButtonBaseStyle.xaml
Normal file
49
HandyControl/Themes/Styles/Base/ToggleButtonBaseStyle.xaml
Normal file
@ -0,0 +1,49 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="ButtonBaseBaseStyle.xaml"></ResourceDictionary>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style x:Key="ToggleButtonBaseStyle" BasedOn="{StaticResource ButtonBaseBaseStyle}" TargetType="{x:Type ToggleButton}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ToggleButton}">
|
||||
<Grid>
|
||||
<Border x:Name="border" CornerRadius="4" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="0" SnapsToDevicePixels="true">
|
||||
<!--点下时显示-->
|
||||
<Grid x:Name="CheckedLayer" Visibility="Collapsed">
|
||||
<Rectangle Height="3" VerticalAlignment="Top" Fill="#1F000000" RadiusX="4" RadiusY="4">
|
||||
<Rectangle.Effect>
|
||||
<BlurEffect Radius="5"></BlurEffect>
|
||||
</Rectangle.Effect>
|
||||
</Rectangle>
|
||||
<Border CornerRadius="4" BorderBrush="#1F000000" BorderThickness="1,0">
|
||||
<Border.Effect>
|
||||
<BlurEffect Radius="3"></BlurEffect>
|
||||
</Border.Effect>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Border>
|
||||
<Border BorderThickness="{TemplateBinding BorderThickness}">
|
||||
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
|
||||
</Border>
|
||||
<!--禁用时显示-->
|
||||
<Rectangle x:Name="EnabledLayer" Fill="#4CFFFFFF" RadiusX="4" RadiusY="4" Visibility="Collapsed"/>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsChecked" Value="true">
|
||||
<Setter TargetName="CheckedLayer" Property="Visibility" Value="Visible"/>
|
||||
<Setter TargetName="border" Property="BorderBrush" Value="#80cccccc"/>
|
||||
<Setter TargetName="border" Property="BorderThickness" Value="4"></Setter>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter TargetName="EnabledLayer" Property="Visibility" Value="Visible"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
184
HandyControl/Themes/Styles/Base/ToggleButtonSwitchBaseStyle.xaml
Normal file
184
HandyControl/Themes/Styles/Base/ToggleButtonSwitchBaseStyle.xaml
Normal file
@ -0,0 +1,184 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="clr-namespace:HandyControl.Controls">
|
||||
|
||||
<Style x:Key="ToggleButtonSwitchBaseStyle" TargetType="{x:Type ToggleButton}">
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||
<Setter Property="Background" Value="{DynamicResource PrimaryBrush}"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="Padding" Value="0 1 0 0"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ToggleButton}">
|
||||
<ControlTemplate.Resources>
|
||||
<SineEase x:Key="RippleEasingFunction" EasingMode="EaseInOut"/>
|
||||
<Storyboard x:Key="ShowRipple">
|
||||
<DoubleAnimation Storyboard.TargetName="RippleThumb" Storyboard.TargetProperty="Opacity"
|
||||
EasingFunction="{StaticResource RippleEasingFunction}"
|
||||
To="0.26" Duration="0"/>
|
||||
<DoubleAnimation Storyboard.TargetName="RippleThumb" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)"
|
||||
EasingFunction="{StaticResource RippleEasingFunction}"
|
||||
From="1" To="2.5" Duration="0:0:0.2"/>
|
||||
<DoubleAnimation Storyboard.TargetName="RippleThumb" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)"
|
||||
EasingFunction="{StaticResource RippleEasingFunction}"
|
||||
From="1" To="2.5" Duration="0:0:0.2"/>
|
||||
</Storyboard>
|
||||
<Storyboard x:Key="HideRipple">
|
||||
<DoubleAnimation Storyboard.TargetName="RippleThumb" Storyboard.TargetProperty="Opacity"
|
||||
EasingFunction="{StaticResource RippleEasingFunction}"
|
||||
To="0" Duration="0:0:0.3"/>
|
||||
</Storyboard>
|
||||
</ControlTemplate.Resources>
|
||||
<Viewbox Width="34">
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="CheckStates">
|
||||
<VisualStateGroup.Transitions>
|
||||
<VisualTransition From="*" To="Checked">
|
||||
<Storyboard>
|
||||
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="ThumbHolder">
|
||||
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
|
||||
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="23.5">
|
||||
<EasingDoubleKeyFrame.EasingFunction>
|
||||
<QuadraticEase EasingMode="EaseOut"/>
|
||||
</EasingDoubleKeyFrame.EasingFunction>
|
||||
</EasingDoubleKeyFrame>
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualTransition>
|
||||
<VisualTransition From="Checked" To="Unchecked">
|
||||
<Storyboard>
|
||||
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="ThumbHolder">
|
||||
<EasingDoubleKeyFrame KeyTime="0" Value="23.5"/>
|
||||
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0">
|
||||
<EasingDoubleKeyFrame.EasingFunction>
|
||||
<QuadraticEase EasingMode="EaseOut"/>
|
||||
</EasingDoubleKeyFrame.EasingFunction>
|
||||
</EasingDoubleKeyFrame>
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualTransition>
|
||||
</VisualStateGroup.Transitions>
|
||||
<VisualState x:Name="Checked">
|
||||
<Storyboard>
|
||||
<DoubleAnimation Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="ThumbHolder"
|
||||
Duration="0" To="23.5" />
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Unchecked">
|
||||
<Storyboard>
|
||||
<DoubleAnimation Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="ThumbHolder"
|
||||
Duration="0" To="0" />
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<Grid>
|
||||
<Rectangle x:Name="Track" Fill="Black" HorizontalAlignment="Left" Height="15" Margin="4.211,5,4.211,0" Stroke="{x:Null}" VerticalAlignment="Top" Width="40" RadiusY="7.5" RadiusX="7.5" Opacity="0.26"/>
|
||||
|
||||
<Grid x:Name="ThumbHolder"
|
||||
HorizontalAlignment="Left" VerticalAlignment="Top">
|
||||
<Ellipse x:Name="RippleThumb"
|
||||
Fill="{DynamicResource LightPrimaryBrush}"
|
||||
Height="25" Width="25"
|
||||
IsHitTestVisible="False"
|
||||
Opacity="0.26"
|
||||
Margin="0"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||
RenderTransformOrigin="0.5,0.5">
|
||||
<Ellipse.RenderTransform>
|
||||
<ScaleTransform ScaleX="1" ScaleY="1"/>
|
||||
</Ellipse.RenderTransform>
|
||||
</Ellipse>
|
||||
<AdornerDecorator>
|
||||
<Ellipse x:Name="Thumb"
|
||||
Fill="#FFFAFAFA" Stroke="{x:Null}"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||
Width="25" Height="25"
|
||||
Margin="0,0,0,0"
|
||||
RenderTransformOrigin="0.5,0.5"
|
||||
Effect="{DynamicResource EffectShadow1}">
|
||||
</Ellipse>
|
||||
</AdornerDecorator>
|
||||
<ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}"
|
||||
Margin="{TemplateBinding Padding}"
|
||||
x:Name="ContentPresenter"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
FlowDirection="LeftToRight"/>
|
||||
<Grid.RenderTransform>
|
||||
<TranslateTransform X="0" Y="0"/>
|
||||
</Grid.RenderTransform>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Viewbox>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsChecked" Value="True">
|
||||
<Setter TargetName="Thumb" Property="Fill" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Background}" />
|
||||
<Setter TargetName="Track" Property="Fill" Value="{DynamicResource LightPrimaryBrush}" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource SecondaryTextBrush}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsChecked" Value="False">
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryBrush}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="Button.IsDefaulted" Value="true"/>
|
||||
<Trigger Property="IsMouseOver" Value="true"/>
|
||||
<Trigger Property="IsPressed" Value="true">
|
||||
<Trigger.EnterActions>
|
||||
<BeginStoryboard Storyboard="{StaticResource ShowRipple}"/>
|
||||
</Trigger.EnterActions>
|
||||
<Trigger.ExitActions>
|
||||
<BeginStoryboard Storyboard="{StaticResource HideRipple}"/>
|
||||
</Trigger.ExitActions>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Opacity" Value=".2" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ToggleButtonIconBaseStyle" TargetType="{x:Type ToggleButton}">
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"></Setter>
|
||||
<Setter Property="Width" Value="{DynamicResource DefaultControlHeight}"/>
|
||||
<Setter Property="Height" Value="{DynamicResource DefaultControlHeight}"/>
|
||||
<Setter Property="Padding" Value="8"></Setter>
|
||||
<Setter Property="controls:IconSwitchElement.Geometry" Value="{x:Null}"></Setter>
|
||||
<Setter Property="controls:IconSwitchElement.GeometrySelected" Value="{x:Null}"></Setter>
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ToggleButton}">
|
||||
<Grid>
|
||||
<!--点击时显示-->
|
||||
<Ellipse x:Name="border" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{TemplateBinding BorderThickness}" Fill="{TemplateBinding Background}" SnapsToDevicePixels="true"></Ellipse>
|
||||
<Ellipse x:Name="PressedLayer" Visibility="Collapsed" Stroke="#1F000000" StrokeThickness="2">
|
||||
<Ellipse.Effect>
|
||||
<BlurEffect Radius="3"></BlurEffect>
|
||||
</Ellipse.Effect>
|
||||
</Ellipse>
|
||||
<ContentControl HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
|
||||
<Path x:Name="PathIcon" Fill="{TemplateBinding Foreground}" SnapsToDevicePixels="True" Stretch="Uniform" Data="{TemplateBinding controls:IconSwitchElement.Geometry}"></Path>
|
||||
</ContentControl>
|
||||
<!--禁用时显示-->
|
||||
<Ellipse x:Name="EnabledLayer" Fill="#4CFFFFFF" Visibility="Collapsed"/>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsChecked" Value="True">
|
||||
<Setter TargetName="PathIcon" Property="Data" Value="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=(controls:IconSwitchElement.GeometrySelected)}"></Setter>
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="true">
|
||||
<Setter TargetName="PressedLayer" Property="Visibility" Value="Visible"/>
|
||||
<Setter TargetName="border" Property="Stroke" Value="#80cccccc"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter TargetName="EnabledLayer" Property="Visibility" Value="Visible"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
85
HandyControl/Themes/Styles/Expander.xaml
Normal file
85
HandyControl/Themes/Styles/Expander.xaml
Normal file
@ -0,0 +1,85 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="clr-namespace:HandyControl.Controls">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="../Basic/Geometries.xaml"></ResourceDictionary>
|
||||
<ResourceDictionary Source="ToggleButton.xaml"></ResourceDictionary>
|
||||
<ResourceDictionary Source="TextBlock.xaml"></ResourceDictionary>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style TargetType="{x:Type Expander}">
|
||||
<Setter Property="Foreground" Value="White"/>
|
||||
<Setter Property="Background" Value="{DynamicResource PrimaryBrush}"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
|
||||
<Setter Property="BorderBrush" Value="Transparent"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="MinHeight" Value="40"></Setter>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Expander}">
|
||||
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<ToggleButton Padding="10,0,0,0" Foreground="{TemplateBinding Foreground}" Grid.ColumnSpan="2" HorizontalContentAlignment="Stretch" IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Width="{TemplateBinding Width}" Height="{TemplateBinding MinHeight}" Style="{StaticResource ToggleButtonOpacityStyle}">
|
||||
<ToggleButton.Content>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="{TemplateBinding MinHeight}"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<ContentPresenter ContentSource="Header"></ContentPresenter>
|
||||
<ToggleButton Grid.Column="1" Padding="0" Margin="0,0,10,0" Width="12" Height="12" VerticalAlignment="Center" HorizontalAlignment="Right" IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" controls:IconSwitchElement.Geometry="{StaticResource DownGeometry}" controls:IconSwitchElement.GeometrySelected="{StaticResource UpGeometry}" Style="{StaticResource ToggleButtonIconTransparent}"></ToggleButton>
|
||||
</Grid>
|
||||
</ToggleButton.Content>
|
||||
</ToggleButton>
|
||||
<ContentPresenter Name="ExpandSite" Visibility="Collapsed" Grid.Row="1" Grid.Column="0"></ContentPresenter>
|
||||
</Grid>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsExpanded" Value="true">
|
||||
<Setter Property="Visibility" TargetName="ExpandSite" Value="Visible"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Opacity" Value="2"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
<!--<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="3" SnapsToDevicePixels="true">
|
||||
<DockPanel>
|
||||
<ToggleButton x:Name="HeaderSite" ContentTemplate="{TemplateBinding HeaderTemplate}" ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}" Content="{TemplateBinding Header}" DockPanel.Dock="Top" Foreground="{TemplateBinding Foreground}" FontWeight="{TemplateBinding FontWeight}" FocusVisualStyle="{StaticResource ExpanderHeaderFocusVisual}" FontStyle="{TemplateBinding FontStyle}" FontStretch="{TemplateBinding FontStretch}" FontSize="{TemplateBinding FontSize}" FontFamily="{TemplateBinding FontFamily}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Margin="1" MinWidth="0" MinHeight="0" Padding="{TemplateBinding Padding}" Style="{StaticResource ExpanderDownHeaderStyle}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
<ContentPresenter x:Name="ExpandSite" DockPanel.Dock="Bottom" Focusable="false" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" Visibility="Collapsed" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
</DockPanel>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsExpanded" Value="true">
|
||||
<Setter Property="Visibility" TargetName="ExpandSite" Value="Visible"/>
|
||||
</Trigger>
|
||||
<Trigger Property="ExpandDirection" Value="Right">
|
||||
<Setter Property="DockPanel.Dock" TargetName="ExpandSite" Value="Right"/>
|
||||
<Setter Property="DockPanel.Dock" TargetName="HeaderSite" Value="Left"/>
|
||||
<Setter Property="Style" TargetName="HeaderSite" Value="{StaticResource ExpanderRightHeaderStyle}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="ExpandDirection" Value="Up">
|
||||
<Setter Property="DockPanel.Dock" TargetName="ExpandSite" Value="Top"/>
|
||||
<Setter Property="DockPanel.Dock" TargetName="HeaderSite" Value="Bottom"/>
|
||||
<Setter Property="Style" TargetName="HeaderSite" Value="{StaticResource ExpanderUpHeaderStyle}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="ExpandDirection" Value="Left">
|
||||
<Setter Property="DockPanel.Dock" TargetName="ExpandSite" Value="Left"/>
|
||||
<Setter Property="DockPanel.Dock" TargetName="HeaderSite" Value="Right"/>
|
||||
<Setter Property="Style" TargetName="HeaderSite" Value="{StaticResource ExpanderLeftHeaderStyle}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>-->
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
@ -26,7 +26,7 @@
|
||||
<!--<ResourceDictionary Source="AnimationPath.xaml"></ResourceDictionary>-->
|
||||
<!--<ResourceDictionary Source="ToolTip.xaml"></ResourceDictionary>-->
|
||||
<!--<ResourceDictionary Source="InfoBrief.xaml"></ResourceDictionary>-->
|
||||
<!--<ResourceDictionary Source="Expander.xaml"></ResourceDictionary>-->
|
||||
<ResourceDictionary Source="Expander.xaml"></ResourceDictionary>
|
||||
<!--<ResourceDictionary Source="TextBox.xaml"></ResourceDictionary>-->
|
||||
<!--<ResourceDictionary Source="ContentControl.xaml"></ResourceDictionary>-->
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
149
HandyControl/Themes/Styles/ToggleButton.xaml
Normal file
149
HandyControl/Themes/Styles/ToggleButton.xaml
Normal file
@ -0,0 +1,149 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="clr-namespace:HandyControl.Controls">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="Base/ToggleButtonBaseStyle.xaml"></ResourceDictionary>
|
||||
<ResourceDictionary Source="Base/ToggleButtonSwitchBaseStyle.xaml"></ResourceDictionary>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<!--普通-->
|
||||
<Style BasedOn="{StaticResource ToggleButtonBaseStyle}" TargetType="{x:Type ToggleButton}">
|
||||
<Setter Property="Background" Value="{DynamicResource DefaultBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource DarkDefaultBrush}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource DarkDefaultBrush}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ToggleButtonPrimary" BasedOn="{StaticResource ToggleButtonBaseStyle}" TargetType="{x:Type ToggleButton}">
|
||||
<Setter Property="Background" Value="{DynamicResource PrimaryBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource DarkPrimaryBrush}"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource DarkPrimaryBrush}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ToggleButtonSuccess" BasedOn="{StaticResource ToggleButtonBaseStyle}" TargetType="{x:Type ToggleButton}">
|
||||
<Setter Property="Background" Value="{DynamicResource SuccessBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource DarkSuccessBrush}"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource DarkSuccessBrush}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ToggleButtonInfo" BasedOn="{StaticResource ToggleButtonBaseStyle}" TargetType="{x:Type ToggleButton}">
|
||||
<Setter Property="Background" Value="{DynamicResource InfoBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource DarkInfoBrush}"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource DarkInfoBrush}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ToggleButtonWarning" BasedOn="{StaticResource ToggleButtonBaseStyle}" TargetType="{x:Type ToggleButton}">
|
||||
<Setter Property="Background" Value="{DynamicResource WarningBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource DarkWarningBrush}"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource DarkWarningBrush}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ToggleButtonDanger" BasedOn="{StaticResource ToggleButtonBaseStyle}" TargetType="{x:Type ToggleButton}">
|
||||
<Setter Property="Background" Value="{DynamicResource DangerBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource DarkDangerBrush}"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource DarkDangerBrush}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<!--开关-->
|
||||
<Style x:Key="ToggleButtonSwitch" BasedOn="{StaticResource ToggleButtonSwitchBaseStyle}" TargetType="{x:Type ToggleButton}"></Style>
|
||||
|
||||
<!--icon-->
|
||||
<Style x:Key="ToggleButtonIcon" BasedOn="{StaticResource ToggleButtonIconBaseStyle}" TargetType="{x:Type ToggleButton}"></Style>
|
||||
|
||||
<Style x:Key="ToggleButtonIconTransparent" BasedOn="{StaticResource ToggleButtonIconBaseStyle}" TargetType="{x:Type ToggleButton}">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="BorderBrush" Value="Transparent"/>
|
||||
<Setter Property="Foreground" Value="White"></Setter>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ToggleButton}">
|
||||
<Border Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
|
||||
<ContentControl Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
|
||||
<Path x:Name="PathIcon" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Fill="{TemplateBinding Foreground}" SnapsToDevicePixels="True" Stretch="Uniform" Data="{TemplateBinding controls:IconSwitchElement.Geometry}"></Path>
|
||||
</ContentControl>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsChecked" Value="True">
|
||||
<Setter TargetName="PathIcon" Property="Data" Value="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=(controls:IconSwitchElement.GeometrySelected)}"></Setter>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Opacity" Value=".9"></Setter>
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter Property="Opacity" Value=".6"></Setter>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Opacity" Value=".2"></Setter>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ToggleButtonOpacityStyle" TargetType="{x:Type ToggleButton}">
|
||||
<Setter Property="Background" Value="Transparent"></Setter>
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"></Setter>
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||
<Setter Property="Padding" Value="0"/>
|
||||
<Setter Property="Focusable" Value="False"></Setter>
|
||||
<Setter Property="IsTabStop" Value="False"/>
|
||||
<Setter Property="BorderThickness" Value="0"></Setter>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ToggleButton}">
|
||||
<Border x:Name="Chrome" SnapsToDevicePixels="true" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}">
|
||||
<Grid>
|
||||
<ContentPresenter Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
|
||||
<ContentPresenter Name="CheckedElement" Visibility="Collapsed" Content="{Binding Path=(controls:StatusSwitchElement.CheckedElement),RelativeSource={RelativeSource TemplatedParent}}"></ContentPresenter>
|
||||
</Grid>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Opacity" Value=".9"></Setter>
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter Property="Opacity" Value=".6"></Setter>
|
||||
</Trigger>
|
||||
<Trigger Property="IsChecked" Value="True">
|
||||
<Setter Property="Visibility" Value="Visible" TargetName="CheckedElement"></Setter>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Opacity" Value=".2"></Setter>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
@ -620,6 +620,32 @@
|
||||
</controls:TabControl>
|
||||
</Grid>
|
||||
</Border>-->
|
||||
<Border Visibility="Visible" Margin="0,10,0,0" Style="{StaticResource BorderRegionStyle}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Header"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel>
|
||||
<TextBlock Margin="0,5,0,0" Style="{StaticResource TextBlockTitle}" Text="展开框"></TextBlock>
|
||||
<TextBlock Style="{StaticResource TextBlockTitle}" Text="(Expander)"></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="1" Margin="50,0,0,0">
|
||||
<Expander Header="标题1" BorderThickness="1,1,1,0" BorderBrush="{StaticResource BorderBrush}" Width="240" HorizontalAlignment="Left">
|
||||
<Border Height="100" Background="{StaticResource BackgroundBrush}"></Border>
|
||||
</Expander>
|
||||
<Expander Header="标题1" BorderThickness="1,1,1,0" BorderBrush="{StaticResource BorderBrush}" Width="240" HorizontalAlignment="Left">
|
||||
<Border Height="100" Background="{StaticResource BackgroundBrush}"></Border>
|
||||
</Expander>
|
||||
<Expander Header="标题1" BorderThickness="1,1,1,0" BorderBrush="{StaticResource BorderBrush}" Width="240" HorizontalAlignment="Left">
|
||||
<Border Height="100" Background="{StaticResource BackgroundBrush}"></Border>
|
||||
</Expander>
|
||||
<Expander Header="标题1" BorderThickness="1" BorderBrush="{StaticResource BorderBrush}" Width="240" HorizontalAlignment="Left">
|
||||
<Border Height="100" Background="{StaticResource BackgroundBrush}"></Border>
|
||||
</Expander>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
<!--步骤条-->
|
||||
<!--<Border Visibility="Collapsed" Margin="0,10,0,0" Style="{StaticResource BorderRegionStyle}">
|
||||
<Grid>
|
||||
|
@ -16,4 +16,8 @@
|
||||
|
||||
### 4、页码条Pagination
|
||||
|
||||
![轮播Pagination](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/Pagination.gif)
|
||||
![轮播Pagination](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/Pagination.gif)
|
||||
|
||||
### 5、展开折叠框Expander
|
||||
|
||||
![展开折叠框Expander](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/Expander.gif)
|
BIN
Resources/Expander.gif
Normal file
BIN
Resources/Expander.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
Loading…
Reference in New Issue
Block a user