更新
This commit is contained in:
199
AntdWpf/Styles/Spin.xaml
Normal file
199
AntdWpf/Styles/Spin.xaml
Normal file
@@ -0,0 +1,199 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="clr-namespace:AntdWpf.Controls">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/AntdWpf;component/Styles/Control.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style BasedOn="{StaticResource Ant.Control}" TargetType="{x:Type controls:Spin}">
|
||||
<Setter Property="IsTabStop" Value="False" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryBrush}" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type controls:Spin}">
|
||||
<Grid>
|
||||
<!-- Content -->
|
||||
<Border x:Name="Content"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}">
|
||||
<ContentPresenter Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
ContentStringFormat="{TemplateBinding ContentStringFormat}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" />
|
||||
</Border>
|
||||
<!-- IndicatorPanel -->
|
||||
<Grid x:Name="IndicatorPanel"
|
||||
VerticalAlignment="Center"
|
||||
Visibility="{Binding Spinning, RelativeSource={RelativeSource TemplatedParent},
|
||||
Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<Grid.RowDefinitions>
|
||||
<!-- Icon -->
|
||||
<RowDefinition />
|
||||
<!-- Text -->
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<!-- Indicator -->
|
||||
<ContentPresenter x:Name="Indicator"
|
||||
Grid.RowSpan="2"
|
||||
Visibility="Hidden"
|
||||
Content="{TemplateBinding Indicator}" />
|
||||
<!-- Dot -->
|
||||
<Grid x:Name="Dot"
|
||||
Grid.RowSpan="2"
|
||||
RenderTransformOrigin="0.5,0.5"
|
||||
Width="{DynamicResource SpinDotSize}"
|
||||
Height="{Binding Width, Mode=OneWay, RelativeSource={RelativeSource Self}}">
|
||||
<Grid.RenderTransform>
|
||||
<RotateTransform />
|
||||
</Grid.RenderTransform>
|
||||
<Grid.Resources>
|
||||
<Style TargetType="{x:Type Ellipse}">
|
||||
<Setter Property="Opacity" Value="0.3" />
|
||||
<Setter Property="RenderTransformOrigin" Value="0.5,0.5" />
|
||||
<Setter Property="Fill" Value="{DynamicResource PrimaryBrush}" />
|
||||
<Setter Property="Height" Value="{Binding Width, Mode=OneWay, RelativeSource={RelativeSource Self}}" />
|
||||
<Setter Property="RenderTransform">
|
||||
<Setter.Value>
|
||||
<ScaleTransform ScaleX="0.75" ScaleY="0.75" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</Grid.Resources>
|
||||
<Ellipse x:Name="Dot1"
|
||||
Width="9"
|
||||
VerticalAlignment="Top"
|
||||
HorizontalAlignment="Left" />
|
||||
<Ellipse x:Name="Dot2"
|
||||
VerticalAlignment="Top"
|
||||
HorizontalAlignment="Right"
|
||||
Width="{Binding Width, Mode=OneWay, ElementName=Dot1}" />
|
||||
<Ellipse x:Name="Dot3"
|
||||
VerticalAlignment="Bottom"
|
||||
HorizontalAlignment="Left"
|
||||
Width="{Binding Width, Mode=OneWay, ElementName=Dot1}" />
|
||||
<Ellipse x:Name="Dot4"
|
||||
VerticalAlignment="Bottom"
|
||||
HorizontalAlignment="Right"
|
||||
Width="{Binding Width, Mode=OneWay, ElementName=Dot1}" />
|
||||
</Grid>
|
||||
<ContentPresenter x:Name="LoadingText" Grid.Row="1" Content="{TemplateBinding Tip}" />
|
||||
</Grid>
|
||||
<!-- Mask -->
|
||||
<Rectangle x:Name="Mask" Fill="Transparent" Visibility="Collapsed" />
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="SpinStates">
|
||||
<VisualStateGroup.Transitions>
|
||||
<VisualTransition From="Spun" GeneratedDuration="0:0:0.2">
|
||||
<Storyboard>
|
||||
<!-- Content -->
|
||||
<DoubleAnimation Storyboard.TargetName="Content"
|
||||
Storyboard.TargetProperty="Opacity" />
|
||||
</Storyboard>
|
||||
</VisualTransition>
|
||||
</VisualStateGroup.Transitions>
|
||||
<VisualState x:Name="Spun">
|
||||
<Storyboard>
|
||||
<!-- Content -->
|
||||
<DoubleAnimation Storyboard.TargetName="Content"
|
||||
Storyboard.TargetProperty="Opacity"
|
||||
Duration="0:0:0.2"
|
||||
To="0.5" />
|
||||
<!-- Dot -->
|
||||
<DoubleAnimation Storyboard.TargetName="Dot"
|
||||
Storyboard.TargetProperty="RenderTransform.Angle"
|
||||
RepeatBehavior="Forever"
|
||||
Duration="0:0:1.2"
|
||||
From="45"
|
||||
To="405" />
|
||||
<DoubleAnimation Storyboard.TargetName="Dot1"
|
||||
Storyboard.TargetProperty="Opacity"
|
||||
RepeatBehavior="Forever"
|
||||
AutoReverse="True"
|
||||
Duration="0:0:1"
|
||||
From="0.3"
|
||||
To="1" />
|
||||
<DoubleAnimation Storyboard.TargetName="Dot2"
|
||||
Storyboard.TargetProperty="Opacity"
|
||||
RepeatBehavior="Forever"
|
||||
AutoReverse="True"
|
||||
BeginTime="0:0:0.4"
|
||||
Duration="0:0:1"
|
||||
From="0.3"
|
||||
To="1" />
|
||||
<DoubleAnimation Storyboard.TargetName="Dot3"
|
||||
Storyboard.TargetProperty="Opacity"
|
||||
RepeatBehavior="Forever"
|
||||
AutoReverse="True"
|
||||
BeginTime="0:0:0.8"
|
||||
Duration="0:0:1"
|
||||
From="0.3"
|
||||
To="1" />
|
||||
<DoubleAnimation Storyboard.TargetName="Dot4"
|
||||
Storyboard.TargetProperty="Opacity"
|
||||
RepeatBehavior="Forever"
|
||||
AutoReverse="True"
|
||||
BeginTime="0:0:1.2"
|
||||
Duration="0:0:1"
|
||||
From="0.3"
|
||||
To="1" />
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Unspun" />
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="Size" Value="Small">
|
||||
<Setter TargetName="Dot1" Property="Width" Value="6" />
|
||||
<Setter TargetName="Dot" Property="Width" Value="{DynamicResource SpinDotSizeSmall}" />
|
||||
</Trigger>
|
||||
<Trigger Property="Size" Value="Large">
|
||||
<Setter TargetName="Dot1" Property="Width" Value="14" />
|
||||
<Setter TargetName="Dot" Property="Width" Value="{DynamicResource SpinDotSizeLarge}" />
|
||||
</Trigger>
|
||||
<!-- Spun State -->
|
||||
<Trigger Property="Spinning" Value="True">
|
||||
<Setter TargetName="Mask" Property="Visibility" Value="Visible" />
|
||||
<Setter TargetName="Content" Property="Effect">
|
||||
<Setter.Value>
|
||||
<BlurEffect Radius="2" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Trigger>
|
||||
<!-- With Loading Text -->
|
||||
<DataTrigger Binding="{Binding Tip, Mode=OneWay, RelativeSource={RelativeSource Self},
|
||||
Converter={StaticResource IsEmptyConverter}}" Value="False">
|
||||
<Setter TargetName="Dot" Property="Grid.RowSpan" Value="1" />
|
||||
<Setter TargetName="Indicator" Property="Grid.RowSpan" Value="1" />
|
||||
<Setter TargetName="LoadingText" Property="Margin" Value="0 8 0 0" />
|
||||
</DataTrigger>
|
||||
<!-- Nested Loading -->
|
||||
<DataTrigger Binding="{Binding Content, Mode=OneWay, RelativeSource={RelativeSource Self},
|
||||
Converter={StaticResource IsNullConverter}}" Value="False">
|
||||
<Setter TargetName="IndicatorPanel" Property="HorizontalAlignment" Value="Center" />
|
||||
</DataTrigger>
|
||||
<!-- With Indicator -->
|
||||
<DataTrigger Binding="{Binding Indicator, Mode=OneWay, RelativeSource={RelativeSource Self},
|
||||
Converter={StaticResource IsNullConverter}}" Value="False">
|
||||
<Setter TargetName="Dot" Property="Visibility" Value="Collapsed" />
|
||||
<Setter TargetName="Indicator" Property="Visibility" Value="Visible" />
|
||||
</DataTrigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<!-- Spun State -->
|
||||
<Trigger Property="Spinning" Value="True">
|
||||
<Setter Property="KeyboardNavigation.TabNavigation" Value="None" />
|
||||
<Setter Property="KeyboardNavigation.DirectionalNavigation" Value="None" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
Reference in New Issue
Block a user