1
時保留LineSegments的角度我創建了一個光滑的面板效果,看起來像這樣:WPF:我如何繪製多邊形調整大小
這是XAML:
<Window x:Class="Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="200" Width="300">
<StackPanel Orientation="Vertical">
<StackPanel.Background>
<DrawingBrush>
<DrawingBrush.Drawing>
<DrawingGroup>
<GeometryDrawing>
<GeometryDrawing.Geometry>
<RectangleGeometry Rect="0,0,1,1"></RectangleGeometry>
</GeometryDrawing.Geometry>
<GeometryDrawing.Brush>
<SolidColorBrush Opacity="0.5" Color="Blue" />
</GeometryDrawing.Brush>
</GeometryDrawing>
<GeometryDrawing>
<GeometryDrawing.Geometry>
<PathGeometry>
<PathGeometry.Figures>
<PathFigureCollection>
<PathFigure IsClosed="True" StartPoint="0,0">
<PathFigure.Segments>
<PathSegmentCollection>
<LineSegment Point="0.3,0" />
<LineSegment Point="0.2,1" />
<LineSegment Point="0,1" />
<LineSegment Point="0,0" />
</PathSegmentCollection>
</PathFigure.Segments>
</PathFigure>
</PathFigureCollection>
</PathGeometry.Figures>
</PathGeometry>
</GeometryDrawing.Geometry>
<GeometryDrawing.Brush>
<LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
<GradientStop Offset="0.0" Color="Transparent" />
<GradientStop Offset="0.7" Color="#58FFFFFF" />
<GradientStop Offset="1.0" Color="#AFFFFFFF" />
</LinearGradientBrush>
</GeometryDrawing.Brush>
</GeometryDrawing>
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
</StackPanel.Background>
</StackPanel>
</Window>
現在,如果我將此窗口調整爲高度的一半,則閃爍的傾斜角度與之前不同:
我明白,上面的代碼應該是這樣的工作,我的問題是:如何創建這樣的多邊形段的角度調整大小上保持同樣的效果?對於半高調整所需的最終結果是:
它的工作原理! 我所期待的,將相對於左上角那個閃爍_freeze_一個解決方案,但我沒有問這樣的問題。 – SinkovecJ