要移动窗体,需要在窗体的MouseDown事件中添加如下代码:
void Window1_MouseDown(object sender, MouseButtonEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
DragMove();
}
}
<Window x:Class="welcome.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Background="{x:Null}" Height="395" Width="667" WindowStyle="None" AllowsTransparency="True">
<Canvas Height="395" Width="667">
<Path Stroke="DarkGray" StrokeThickness="1" Canvas.Left="0" Width="667" Height="395">
<Path.Data>
<PathGeometry>
<PathFigure StartPoint="0,20" IsClosed="True">
<LineSegment Point="0,375"></LineSegment>
<ArcSegment Point="20,395" Size="20,20" ></ArcSegment>
<LineSegment Point="647,395"></LineSegment>
<ArcSegment Point="667,375" Size="20,20"></ArcSegment>
<LineSegment Point="667,20"></LineSegment>
<ArcSegment Point="647,0" Size="20,20"></ArcSegment>
<LineSegment Point="20,0"></LineSegment>
<ArcSegment Point="0,20" Size="20,20"></ArcSegment>
</PathFigure>
</PathGeometry>
</Path.Data>
<Path.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
<GradientStop Color="LightYellow" Offset="0.25"></GradientStop>
<GradientStop Color="Yellow" Offset="0.5"></GradientStop>
<GradientStop Color="Orange" Offset="0.75"></GradientStop>
<GradientStop Color="OrangeRed" Offset="1"></GradientStop>
</LinearGradientBrush>
</Path.Fill>
</Path>
</Canvas>
</Window>