问题产生:只设置了Angle角度的图像会默认以左上角(即0,0点)旋转
<Window x:Class="MyStoreForWork.Windows.LoginWindow"
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:MyStoreForWork.Windows"
mc:Ignorable="d"
Background="#138CB7"
WindowStartupLocation="CenterScreen"
Title="登录窗口" Height="500" Width="800">
<Grid>
<Border Width="420" Height="300"
Background="White"
BorderBrush="#B6BABE"
BorderThickness="1"
Panel.ZIndex="99"
></Border>
<Border Width="420" Height="300"
Background="White"
BorderBrush="#B6BABE"
BorderThickness="1"
>
<Border.RenderTransform>
<RotateTransform CenterX="210" CenterY="150" Angle="2"></RotateTransform>
</Border.RenderTransform>
</Border>
<Border Width="420" Height="300"
Background="White"
BorderBrush="#B6BABE"
BorderThickness="1"
>
<Border.RenderTransform>
<RotateTransform CenterX="210" CenterY="150" Angle="-2"/>
</Border.RenderTransform>
</Border>
</Grid>
</Window>
效果图如下:
参考链接:如何:旋转对象 - WPF .NET Framework | Microsoft Learn
关键点就是:设计好centerX和centerY,默认是左上角