月更
This commit is contained in:
191
AntDesignWPF/Styles/Alert.xaml
Normal file
191
AntDesignWPF/Styles/Alert.xaml
Normal file
@@ -0,0 +1,191 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:Behaviors="clr-namespace:AntDesign.WPF.Behaviors"
|
||||
xmlns:controls="clr-namespace:AntDesign.WPF.Controls"
|
||||
xmlns:helpers="clr-namespace:AntDesign.WPF.Helpers"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/AntDesign.WPF;component/Styles/Animations.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/AntDesign.WPF;component/Styles/Control.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style BasedOn="{StaticResource Ant.Control}" TargetType="{x:Type controls:Alert}">
|
||||
<Setter Property="Padding" Value="15,8" />
|
||||
<Setter Property="IsTabStop" Value="False" />
|
||||
<Setter Property="SnapsToDevicePixels" Value="True" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
<Setter Property="HorizontalContentAlignment" Value="Left" />
|
||||
<Setter Property="KeyboardNavigation.TabNavigation" Value="None" />
|
||||
<Setter Property="KeyboardNavigation.DirectionalNavigation" Value="None" />
|
||||
<Setter Property="IconBrush" Value="{DynamicResource InfoBrush}" />
|
||||
<Setter Property="BorderThickness" Value="{DynamicResource BorderThicknessBase}" />
|
||||
<Setter Property="helpers:AntdControl.BorderStyle" Value="{DynamicResource BorderStyleBase}" />
|
||||
<Setter Property="helpers:AntdControl.CornerRadius" Value="{DynamicResource BorderRadiusBase}" />
|
||||
<Setter Property="Background" Value="{Binding IconBrush, Mode=OneWay, RelativeSource={RelativeSource Self}, Converter={StaticResource ColorPaletteConverter}, ConverterParameter=1}" />
|
||||
<Setter Property="BorderBrush" Value="{Binding IconBrush, Mode=OneWay, RelativeSource={RelativeSource Self}, Converter={StaticResource ColorPaletteConverter}, ConverterParameter=3}" />
|
||||
<Setter Property="RenderTransform">
|
||||
<Setter.Value>
|
||||
<ScaleTransform />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Behaviors:StylizedBehaviors.Behaviors">
|
||||
<Setter.Value>
|
||||
<Behaviors:StylizedBehaviorCollection>
|
||||
<Behaviors:VisibilityBehavior>
|
||||
<Behaviors:VisibilityBehavior.Leave>
|
||||
<Storyboard FillBehavior="Stop">
|
||||
<DoubleAnimation
|
||||
Duration="0:0:0.3"
|
||||
EasingFunction="{StaticResource EaseInOutCirc}"
|
||||
From="1"
|
||||
Storyboard.TargetProperty="Opacity"
|
||||
To="0" />
|
||||
<DoubleAnimation
|
||||
Duration="0:0:0.3"
|
||||
EasingFunction="{StaticResource EaseInOutCirc}"
|
||||
From="1"
|
||||
Storyboard.TargetProperty="RenderTransform.ScaleY"
|
||||
To="0" />
|
||||
</Storyboard>
|
||||
</Behaviors:VisibilityBehavior.Leave>
|
||||
</Behaviors:VisibilityBehavior>
|
||||
</Behaviors:StylizedBehaviorCollection>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type controls:Alert}">
|
||||
<controls:AntdBorder
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderStyle="{TemplateBinding helpers:AntdControl.BorderStyle}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="{TemplateBinding helpers:AntdControl.CornerRadius}"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
|
||||
UseLayoutRounding="True">
|
||||
<Grid>
|
||||
<Grid.Resources>
|
||||
<!-- TODO Does it have other uses? -->
|
||||
<Style TargetType="{x:Type Button}" x:Key="Ant.AlertCloseButton">
|
||||
<Setter Property="Padding" Value="0" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource LinkBrush}" />
|
||||
<Setter Property="FontSize" Value="{DynamicResource FontSizeSmall}" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Button}">
|
||||
<ControlTemplate.Resources>
|
||||
<Style TargetType="{x:Type controls:Icon}">
|
||||
<Setter Property="Opacity" Value="0.65" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource HeadingBrush}" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Opacity" Value="0.85" />
|
||||
</Trigger>
|
||||
<DataTrigger Binding="{Binding IsPressed, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type Button}}}" Value="True">
|
||||
<Setter Property="Opacity" Value="1" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ControlTemplate.Resources>
|
||||
<ContentPresenter />
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Foreground" Value="{DynamicResource LinkHoverBrush}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter Property="Foreground" Value="{DynamicResource LinkActiveBrush}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Grid.Resources>
|
||||
<Grid.ColumnDefinitions>
|
||||
<!-- Icon -->
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<!-- Text -->
|
||||
<ColumnDefinition Width="*" />
|
||||
<!-- Close Button -->
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<!-- Message -->
|
||||
<RowDefinition />
|
||||
<!-- Description -->
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<!-- Icon -->
|
||||
<controls:Icon
|
||||
Foreground="{TemplateBinding IconBrush}"
|
||||
Margin="0,0,8,0"
|
||||
Theme="Filled"
|
||||
Type="{TemplateBinding Icon}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
Visibility="{Binding ShowIcon, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
x:Name="Icon" />
|
||||
<!-- Message -->
|
||||
<ContentPresenter
|
||||
Content="{Binding Message, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource StringToTextBlockConverter}}"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
x:Name="Message" />
|
||||
<!-- Description -->
|
||||
<ContentPresenter
|
||||
Content="{Binding Description, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource StringToTextBlockConverter}}"
|
||||
Grid.Column="1"
|
||||
Grid.ColumnSpan="2"
|
||||
Grid.Row="1"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
Visibility="Collapsed"
|
||||
x:Name="Description" />
|
||||
<!-- Close Button -->
|
||||
<Button
|
||||
Grid.Column="2"
|
||||
Style="{StaticResource Ant.AlertCloseButton}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
x:Name="PART_Close" />
|
||||
</Grid>
|
||||
</controls:AntdBorder>
|
||||
<ControlTemplate.Triggers>
|
||||
<!-- With Description -->
|
||||
<DataTrigger Binding="{Binding Description, Mode=OneWay, RelativeSource={RelativeSource Self}, Converter={StaticResource IsNullConverter}}" Value="False">
|
||||
<Setter Property="FontSize" TargetName="Icon" Value="24" />
|
||||
<Setter Property="Theme" TargetName="Icon" Value="Outlined" />
|
||||
<Setter Property="Margin" TargetName="Message" Value="0,0,0,4" />
|
||||
<Setter Property="Visibility" TargetName="Description" Value="Visible" />
|
||||
<Setter Property="FontSize" TargetName="PART_Close" Value="{DynamicResource FontSizeBase}" />
|
||||
<Setter Property="TextElement.FontSize" TargetName="Message" Value="{DynamicResource FontSizeLarge}" />
|
||||
<Setter Property="TextElement.Foreground" TargetName="Message" Value="{DynamicResource HeadingBrush}" />
|
||||
</DataTrigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="Type" Value="Info">
|
||||
<Setter Property="Icon" Value="info-circle" />
|
||||
</Trigger>
|
||||
<Trigger Property="Type" Value="Success">
|
||||
<Setter Property="Icon" Value="check-circle" />
|
||||
<Setter Property="IconBrush" Value="{DynamicResource SuccessBrush}" />
|
||||
</Trigger>
|
||||
<Trigger Property="Type" Value="Warning">
|
||||
<Setter Property="Icon" Value="exclamation-circle" />
|
||||
<Setter Property="IconBrush" Value="{DynamicResource WarningBrush}" />
|
||||
</Trigger>
|
||||
<Trigger Property="Type" Value="Error">
|
||||
<Setter Property="Icon" Value="close-circle" />
|
||||
<Setter Property="IconBrush" Value="{DynamicResource ErrorBrush}" />
|
||||
</Trigger>
|
||||
<Trigger Property="Banner" Value="True">
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="helpers:AntdControl.CornerRadius" Value="0" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
Reference in New Issue
Block a user