Files
Shrlalgo.RvKits/WPFluent/Controls/InfoBar/InfoBar.xaml
ShrlAlgo 4d35cadb56 更新
2025-07-11 09:20:23 +08:00

134 lines
8.4 KiB
XML

<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">
<!--<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/WPFluent;component/Themes/Light.xaml"/>
</ResourceDictionary.MergedDictionaries>-->
<Thickness x:Key="InfoBarPadding">14,8,14,8</Thickness>
<Thickness x:Key="InfoBarBorderThemeThickness">1</Thickness>
<Style TargetType="{x:Type controls:InfoBar}">
<Setter Property="Background" Value="{DynamicResource ControlFillColorDefaultBrush}"/>
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}" />
<Setter Property="Padding" Value="{StaticResource InfoBarPadding}" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="BorderBrush" Value="{DynamicResource CardStrokeColorDefaultBrush}" />
<Setter Property="BorderThickness" Value="{StaticResource InfoBarBorderThemeThickness}" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="Border.CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
<Setter Property="Focusable" Value="False" />
<Setter Property="KeyboardNavigation.IsTabStop" Value="False" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:InfoBar}">
<Grid x:Name="InfoBarRoot">
<Border
x:Name="ContentBorder"
Padding="16,14,16,10"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
VerticalAlignment="{TemplateBinding VerticalAlignment}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding Border.CornerRadius}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Border Margin="0,2,20,0" VerticalAlignment="Top">
<controls:SymbolIcon
x:Name="SymbolIcon"
VerticalAlignment="Top"
Filled="True"
FontSize="16" />
</Border>
<WrapPanel Grid.Column="1" VerticalAlignment="Top">
<TextBlock
x:Name="InfoTitle"
Margin="0,0,14,0"
ScrollViewer.CanContentScroll="False"
Text="{TemplateBinding Title}"
TextElement.FontSize="{TemplateBinding FontSize}"
TextElement.FontWeight="SemiBold"
TextWrapping="Wrap" />
<TextBlock
Margin="0"
ScrollViewer.CanContentScroll="False"
Text="{TemplateBinding Message}"
TextElement.FontSize="{TemplateBinding FontSize}"
TextWrapping="Wrap" />
</WrapPanel>
<Border
Grid.Column="2"
Margin="12,-2,0,0"
VerticalAlignment="Top">
<controls:Button
x:Name="CloseButton"
Padding="4"
Background="Transparent"
BorderThickness="0"
Command="{Binding Path=TemplateButtonCommand, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
IsEnabled="True">
<controls:Button.Icon>
<controls:SymbolIcon Symbol="Dismiss24" />
</controls:Button.Icon>
</controls:Button>
</Border>
</Grid>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger SourceName="InfoTitle" Property="Text" Value="">
<Setter TargetName="InfoTitle" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="IsClosable" Value="False">
<Setter TargetName="CloseButton" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="IsOpen" Value="True">
<Setter Property="Visibility" Value="Visible" />
</Trigger>
<Trigger Property="IsOpen" Value="False">
<Setter Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="Severity" Value="Attention">
<Setter TargetName="SymbolIcon" Property="Foreground" Value="{DynamicResource SystemFillColorAttentionBrush}"/>
<Setter TargetName="SymbolIcon" Property="Symbol" Value="Info24" />
<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource SystemFillColorAttentionBackgroundBrush}" />
</Trigger>
<Trigger Property="Severity" Value="Success">
<Setter TargetName="SymbolIcon" Property="Foreground" Value="{DynamicResource SystemFillColorSuccessBrush}" />
<Setter TargetName="SymbolIcon" Property="Symbol" Value="CheckmarkCircle24" />
<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource SystemFillColorSuccessBackgroundBrush}" />
</Trigger>
<Trigger Property="Severity" Value="Caution">
<Setter TargetName="SymbolIcon" Property="Foreground" Value="{DynamicResource SystemFillColorCautionBrush}" />
<Setter TargetName="SymbolIcon" Property="Symbol" Value="ErrorCircle24" />
<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource SystemFillColorCautionBackgroundBrush}" />
</Trigger>
<Trigger Property="Severity" Value="Critical">
<Setter TargetName="SymbolIcon" Property="Foreground" Value="{DynamicResource SystemFillColorCriticalBrush}" />
<Setter TargetName="SymbolIcon" Property="Symbol" Value="DismissCircle24" />
<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource SystemFillColorCriticalBackgroundBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>