bit*_*onk 6 wpf geometry stretch
我需要在Border控件(或类似)中绘制一些简单的线条,这些线条始终延伸到Border的边界.有没有办法只拉伸线而不是它的笔?没有涉及大量的C#?
在这个版本中,线条伸展:
<Border>
<Border.Background>
<DrawingBrush>
<DrawingBrush.Drawing>
<DrawingGroup>
<GeometryDrawing Brush="Red">
<GeometryDrawing.Geometry>
<GeometryGroup>
<RectangleGeometry Rect="0,0 100,1000" />
<LineGeometry StartPoint="0,0" EndPoint="100,1000"/>
<LineGeometry StartPoint="100,0" EndPoint="0,1000"/>
</GeometryGroup>
</GeometryDrawing.Geometry>
<GeometryDrawing.Pen>
<Pen Thickness="20" Brush="Black"/>
</GeometryDrawing.Pen>
</GeometryDrawing>
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
</Border.Background>
</Border>
Run Code Online (Sandbox Code Playgroud)
我提出的最佳解决方案是:
<Border>
<Grid>
<Path Stretch="Fill" Fill="Red" Stroke="Black" StrokeThickness="4" Data="M0,0 L100,0 100,1000 0,1000 z" />
<Path Stretch="Fill" Stroke="Black" StrokeThickness="4" Data="M 0,0 L0,0 100,1000" />
<Path Stretch="Fill" Stroke="Black" StrokeThickness="4" Data="M 100,0 L100,0 0,1000" />
</Grid>
</Border>
Run Code Online (Sandbox Code Playgroud)
但是没有更好的解决方案吗?这不涉及额外的网格?
我通过缩放Path的数据而不是可视组件来完成此操作.
| 归档时间: |
|
| 查看次数: |
5930 次 |
| 最近记录: |