WPF Window Drop-Shadow 效果有方角
WPF Window Drop-Shadow effect has square corners
我一直在尝试让这个投影效果发挥作用,但我不知道哪里出了问题。
我试过给 Grid
和 Border
赋予相同的效果,但它们都赋予相同的效果。
<Window x:Class="New_EZexeat.ReturnMessageDialogueBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:local="clr-namespace:New_EZexeat"
mc:Ignorable="d"
WindowStyle="None" WindowStartupLocation="CenterScreen" AllowsTransparency="True" Background="Transparent"
Title="ReturnMessageDialogueBox" Height="150" Width="300">
<Window.Effect>
<DropShadowEffect Direction="-75" ShadowDepth="2" Opacity="0.8" BlurRadius="25" Color="Black"/>
</Window.Effect>
<Grid Background="Transparent">
<Border Background="White" CornerRadius="20">
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock x:Name="itstext"
FontSize="15"
FontWeight="SemiBold"
Margin="0 0 0 10"
TextAlignment="Center"><Run Text="Username or Password is incorrect."/><LineBreak/><Run Text=" Please try again"/></TextBlock>
<Button Content="OK"
Style="{StaticResource OrangeButtonTemplate}"
FontWeight="SemiBold"
FontSize="20"
Background="#FFFFD411"
Margin="20 0 20 0"
IsCancel="True"
FocusVisualStyle="{x:Null}"
BorderBrush="{x:Null}"
Height="45"/>
</StackPanel>
</Border>
</Grid>
</Window>
要使投影效果起作用,不能将其应用于 window,必须将其应用于网格或边框。在下面的示例中,它被添加到给定的新边框中。
<Border BorderBrush="Transparent" BorderThickness="20" CornerRadius="5" Background="Transparent">
<Border BorderBrush="Black" BorderThickness="1" CornerRadius="5" Background="#3BB2EA">
<Border.Effect>
<DropShadowEffect Direction="-75" ShadowDepth="2" Opacity="0.8" BlurRadius="25" Color="Black"/>
</Border.Effect>
<Border BorderBrush="#55FFFFFF" BorderThickness="1" CornerRadius="5">
<DockPanel Background="white">
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock x:Name="itstext"
FontSize="15"
FontWeight="SemiBold"
Margin="0 0 0 10"
TextAlignment="Center"><Run Text="Username or Password is incorrect."/><LineBreak/><Run Text=" Please try again"/></TextBlock>
<Button Content="OK"
Style="{StaticResource OrangeButtonTemplate}"
FontWeight="SemiBold"
FontSize="20"
Background="#FFFFD411"
Margin="20 0 20 0"
IsCancel="True"
FocusVisualStyle="{x:Null}"
BorderBrush="{x:Null}"
Height="45"/>
</StackPanel>
</DockPanel>
</Border>
</Border>
</Border>
我一直在尝试让这个投影效果发挥作用,但我不知道哪里出了问题。
我试过给 Grid
和 Border
赋予相同的效果,但它们都赋予相同的效果。
<Window x:Class="New_EZexeat.ReturnMessageDialogueBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:local="clr-namespace:New_EZexeat"
mc:Ignorable="d"
WindowStyle="None" WindowStartupLocation="CenterScreen" AllowsTransparency="True" Background="Transparent"
Title="ReturnMessageDialogueBox" Height="150" Width="300">
<Window.Effect>
<DropShadowEffect Direction="-75" ShadowDepth="2" Opacity="0.8" BlurRadius="25" Color="Black"/>
</Window.Effect>
<Grid Background="Transparent">
<Border Background="White" CornerRadius="20">
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock x:Name="itstext"
FontSize="15"
FontWeight="SemiBold"
Margin="0 0 0 10"
TextAlignment="Center"><Run Text="Username or Password is incorrect."/><LineBreak/><Run Text=" Please try again"/></TextBlock>
<Button Content="OK"
Style="{StaticResource OrangeButtonTemplate}"
FontWeight="SemiBold"
FontSize="20"
Background="#FFFFD411"
Margin="20 0 20 0"
IsCancel="True"
FocusVisualStyle="{x:Null}"
BorderBrush="{x:Null}"
Height="45"/>
</StackPanel>
</Border>
</Grid>
</Window>
要使投影效果起作用,不能将其应用于 window,必须将其应用于网格或边框。在下面的示例中,它被添加到给定的新边框中。
<Border BorderBrush="Transparent" BorderThickness="20" CornerRadius="5" Background="Transparent">
<Border BorderBrush="Black" BorderThickness="1" CornerRadius="5" Background="#3BB2EA">
<Border.Effect>
<DropShadowEffect Direction="-75" ShadowDepth="2" Opacity="0.8" BlurRadius="25" Color="Black"/>
</Border.Effect>
<Border BorderBrush="#55FFFFFF" BorderThickness="1" CornerRadius="5">
<DockPanel Background="white">
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock x:Name="itstext"
FontSize="15"
FontWeight="SemiBold"
Margin="0 0 0 10"
TextAlignment="Center"><Run Text="Username or Password is incorrect."/><LineBreak/><Run Text=" Please try again"/></TextBlock>
<Button Content="OK"
Style="{StaticResource OrangeButtonTemplate}"
FontWeight="SemiBold"
FontSize="20"
Background="#FFFFD411"
Margin="20 0 20 0"
IsCancel="True"
FocusVisualStyle="{x:Null}"
BorderBrush="{x:Null}"
Height="45"/>
</StackPanel>
</DockPanel>
</Border>
</Border>
</Border>