<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:flyctrl="clr-namespace:FLY.ControlLibrary;assembly=FLY.ControlLibrary"> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Colors.xaml"/> </ResourceDictionary.MergedDictionaries> <!--toggleSwitchButton 默认样式--> <Style TargetType="flyctrl:NoToggleButton" x:Key="NoToggleButtonStyle"> <Setter Property="Margin" Value="5"/> <Setter Property="HorizontalContentAlignment" Value="Center"/> <Setter Property="VerticalContentAlignment" Value="Center"/> <Setter Property="Padding" Value="1"/> <Setter Property="Width" Value="82"/> <Setter Property="OffBrush" Value="{StaticResource Color_theme_static}" /> <Setter Property="OnBrush" Value="{StaticResource Color_theme_activity}" /> <Setter Property="OffLabel" Value="{Binding Content,RelativeSource={RelativeSource Mode=Self}}" /> <Setter Property="OnLabel" Value="{Binding Content,RelativeSource={RelativeSource Mode=Self}}" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="flyctrl:NoToggleButton"> <Border x:Name="canvas" Width="{TemplateBinding Width}" Background="{TemplateBinding OffBrush}"> <Grid> <Rectangle x:Name="Path_block" Height="33" Width="18" Margin="5" Fill="White" HorizontalAlignment="Left"/> <StackPanel x:Name="SP_Text" Orientation="Horizontal" Margin="15,0" HorizontalAlignment="Right" VerticalAlignment="Center"> <TextBlock x:Name="TB_OnOff" Text="{TemplateBinding Property=OffLabel}" Foreground="White" FontSize="18" FontFamily="Global Sans Serif"/> </StackPanel> </Grid> </Border> <ControlTemplate.Triggers> <Trigger Property="IsChecked" Value="True"> <Setter TargetName="Path_block" Property="HorizontalAlignment" Value="Right"/> <Setter TargetName="SP_Text" Property="HorizontalAlignment" Value="Left"/> <Setter TargetName="TB_OnOff" Property="Text" Value="{Binding OnLabel,RelativeSource={RelativeSource Mode=TemplatedParent}}"/> <Setter TargetName="canvas" Property="Background" Value="{Binding OnBrush,RelativeSource={RelativeSource Mode=TemplatedParent}}" /> </Trigger> <Trigger Property="IsPressed" Value="true"> <!--块移到中间--> <Setter TargetName="Path_block" Property="HorizontalAlignment" Value="Center"/> <Setter TargetName="TB_OnOff" Property="Opacity" Value="0.5"/> <Setter Property="Opacity" Value="1"/> </Trigger> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Opacity" Value="0.7"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> <Style TargetType="flyctrl:NoToggleButton" BasedOn="{StaticResource NoToggleButtonStyle}"/> </ResourceDictionary>