使用异形窗体,可以将窗体的背景设置为透明,边框设置为空,然后利用控件做出异形的窗体,例如:
XAML:
<Window x:Class="WpfWindow.CustomerWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="NonRectangularWindowSample" SizeToContent="WidthAndHeight"
MouseLeftButtonDown="NonRectangularWindow_MouseLeftButtonDown"
WindowStyle="None"
AllowsTransparency="True"
Background="Transparent">
<Canvas Width="200" Height="200" >
<Path Stroke="DarkGray" StrokeThickness="2">
<Path.Fill>
<LinearGradientBrush StartPoint="0.2,0" EndPoint="0.8,1" >
<GradientStop Color="White" Offset="0"></GradientStop>
<GradientStop Color="White" Offset="0.45"></GradientStop>