2017-10-10 44 views
0

我想创建一个不规则形状的窗口。我做了类似于我最终想要创造的东西,但我想要一些圆角的东西。我在某处读到PolyLineSegment无法实现,您能否告诉我如何创建它?我应该使用什么对象/对象集合?如何使PolyLineSegment的角落变圆?

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
       xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
       xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
       mc:Ignorable="d" 
       d:DesignHeight="250" d:DesignWidth="400" 
       AllowsTransparency="True" 
       OpacityMask="White" 
       WindowStyle="None" 
       Background="Transparent" 
       > 
     <Canvas> 
     <Path Height="250" 
       Stroke="Gray" 
       StrokeThickness="2" 
       Name="UIPath" 

       > 
      <Path.Fill> 
      <SolidColorBrush Color="Aqua"> 
      </SolidColorBrush> 
      </Path.Fill> 
      <Path.Data> 
      <PathGeometry> 
       <PathFigureCollection> 
       <PathFigure StartPoint="0,0" 
          IsClosed="True"> 
        <PolyLineSegment IsSmoothJoin="True" Points="400,000" /> 

        <PolyLineSegment IsSmoothJoin="True" 
            Points="400,200" /> 
        <PolyLineSegment IsSmoothJoin="True" 
            Points="180,200" /> 

        <PolyLineSegment IsSmoothJoin="True" 
            Points="200,250" /> 
        <PolyLineSegment IsSmoothJoin="True" 
            Points="100,200" /> 

        <PolyLineSegment IsSmoothJoin="True" 
            Points="00,200" /> 

       </PathFigure> 
       </PathFigureCollection> 
      </PathGeometry> 
      </Path.Data> 
      <Path.ContextMenu> 
      <ContextMenu> 
       <MenuItem Header="Minimize" 
         Name="mnuInvokeMinimize" /> 
       <MenuItem Header="Maximize" 
         Name="mnuInvokeMaximize" /> 
       <MenuItem Header="Restore Down" 
         Name="mnuInvokeRestore" /> 
       <MenuItem Header="Close" 
         Name="mnuInvokeClose" /> 
      </ContextMenu> 
      </Path.ContextMenu> 
      <Path.RenderTransform> 
      <TransformGroup x:Name="pathTfg"> 
       <ScaleTransform ScaleX="1" 
           ScaleY="1" /> 
       <TranslateTransform /> 
      </TransformGroup> 
      </Path.RenderTransform> 
     </Path> 
     </Canvas> 
    </Window> 

回答

1

你可以使用一个CombinedGeometryRectangleGeometry圆角和其余部分PathGeometry

<Path Fill="Aqua" Stroke="Gray" StrokeThickness="2"> 
    <Path.Data> 
     <CombinedGeometry> 
      <CombinedGeometry.Geometry1> 
       <RectangleGeometry Rect="0,0,400,200" RadiusX="20" RadiusY="20"/> 
      </CombinedGeometry.Geometry1> 
      <CombinedGeometry.Geometry2> 
       <PathGeometry Figures="M180,200 L200,250 100,200"/> 
      </CombinedGeometry.Geometry2> 
     </CombinedGeometry> 
    </Path.Data> 
</Path>