要件の背景
私たちが書いたプログラムがリリースされると、ユーザーはいくつかの危険な操作を行っています。私たちのソフトウェアは、境界線のエッジが赤であるなど、いくつかのリマインダー効果を与える必要があります。

ロジックの実装
ボーダー要素Borderを準備するには、境界線、線の色、エフェクトを設定します。エフェクトをDropShadowEffectに設定します。さらに重要なのは、DropShadowEffectのBlurRadiusとColorプロパティです。
難易度は高い。
境界線の色が透明色の場合、DropShadowEffectが設定されている場合は動作しません。
ソリューションSolutions
境界線の色に任意の色を設定します。できれば単色です。次に、グリッドのClipToBoundsプロパティを使用して境界線の余分な色を切り取ります。この時点で、境界線は非常に太いことがわかりますが、これは理想的な効果ではありません。この時点で、逆に考えて、境界線のマージンを負に設定します。例えば、BorderThicknessは10です。マージンを-10に設定すると、目的の効果が表示されます。

<Grid CacheMode="BitmapCache" ClipToBounds="True">
<Border Margin="-10"
BorderBrush="#FFFF"
BorderThickness="10"
CacheMode="BitmapCache">
<Border.Effect>
<DropShadowEffect
BlurRadius="40"
Direction="275"
RenderingBias="Performance"
ShadowDepth="0"
Color="Red" />
</Border.Effect>
</Border>
<Border
Margin="-10"
BorderBrush="#FFFF"
BorderThickness="10"
CacheMode="BitmapCache">
<Border.Effect>
<DropShadowEffect
BlurRadius="40"
Direction="275"
RenderingBias="Performance"
ShadowDepth="0"
Color="Red" />
</Border.Effect>
</Border>
</Grid>
色が明るすぎる場合は、いくつかの重ね合わせを追加することができます。
** 注意:記事は真剣に読んで理解して再利用する必要があります、コピー &ペーストしないでください、魚を与えるよりも魚を与えるよりも魚を与える、忍耐強く理解してください!! **
ウェブマスターはオリジナルの著者コードに従ってAvaloniaバージョンを実装しました。

コードは以下のとおり。
<u:UrsaWindow xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:u="https://irihi.tech/ursa"
mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="450"
Width="400" Height="450"
x:Class="DeviceMrgSample.Views.WarningWindow"
Title="WarningWindow">
<u:UrsaWindow.Styles>
<Style Selector="Border.warning-border">
<Style.Animations>
<Animation Duration="0:0:05"
IterationCount="Infinite"
PlaybackDirection="Alternate">
<KeyFrame Cue="0%">
<Setter Property="Opacity" Value="0.5"/>
</KeyFrame>
<KeyFrame Cue="100%">
<Setter Property="Opacity" Value="1"/>
</KeyFrame>
</Animation>
</Style.Animations>
</Style>
<Style Selector="Grid#gridRoot > TranslateTransform">
<Style.Animations>
<Animation Duration="0:0:0.3"
IterationCount="Infinite">
<KeyFrame Cue="0%">
<Setter Property="X" Value="0"/>
<Setter Property="Y" Value="0"/>
</KeyFrame>
<KeyFrame Cue="20%">
<Setter Property="X" Value="-10"/>
<Setter Property="Y" Value="5"/>
</KeyFrame>
<KeyFrame Cue="40%">
<Setter Property="X" Value="8"/>
<Setter Property="Y" Value="-7"/>
</KeyFrame>
<KeyFrame Cue="60%">
<Setter Property="X" Value="-12"/>
<Setter Property="Y" Value="3"/>
</KeyFrame>
<KeyFrame Cue="80%">
<Setter Property="X" Value="9"/>
<Setter Property="Y" Value="-4"/>
</KeyFrame>
<KeyFrame Cue="100%">
<Setter Property="X" Value="0"/>
<Setter Property="Y" Value="0"/>
</KeyFrame>
</Animation>
</Style.Animations>
</Style>
</u:UrsaWindow.Styles>
<Grid x:Name="gridRoot" ClipToBounds="True">
<Grid.RenderTransform>
<TranslateTransform/>
</Grid.RenderTransform>
<Border Classes="warning-border"
Margin="-25"
BorderBrush="#FFFF"
BorderThickness="25">
<Border.Effect>
<DropShadowEffect
BlurRadius="40"
OffsetX="0"
OffsetY="0"
Opacity="0.8"
Color="Red" />
</Border.Effect>
</Border>
<Border
Margin="-15"
BorderBrush="#FFFF"
BorderThickness="15">
<Border.Effect>
<DropShadowEffect
BlurRadius="40"
OffsetX="0"
OffsetY="0"
Color="Red" />
</Border.Effect>
</Border>
<StackPanel VerticalAlignment="Center"
HorizontalAlignment="Center"
Margin="40">
<TextBlock Text="❗ 磁盘告警 ❗"
FontSize="36"
FontWeight="Black"
Foreground="#FFFF00"
Margin="0 0 0 30"
TextAlignment="Center">
<TextBlock.Effect>
<DropShadowEffect Color="#CC0000"
BlurRadius="12"
OffsetX="2"
OffsetY="2"/>
</TextBlock.Effect>
</TextBlock>
<TextBlock Text="D盘剩余空间不足2GB(20%)"
FontSize="26"
FontWeight="Bold"
Foreground="#FFEB3B"
TextWrapping="Wrap"
MaxWidth="280"
Margin="0 0 0 20"
TextAlignment="Center">
<TextBlock.Effect>
<DropShadowEffect Color="#B71C1C"
BlurRadius="8"
OffsetX="1"
OffsetY="1"/>
</TextBlock.Effect>
</TextBlock>
<TextBlock Text="请立即清理,避免系统崩溃!"
FontSize="24"
FontWeight="SemiBold"
Foreground="#FFEE58"
TextAlignment="Center"
Margin="0 10 0 0">
<TextBlock.Effect>
<DropShadowEffect Color="#C62828"
BlurRadius="6"
OffsetX="1"
OffsetY="1"/>
</TextBlock.Effect>
</TextBlock>
</StackPanel>
</Grid>
</u:UrsaWindow>