我可以使用以下 XAML 创建多边形:
<Polygon Grid.Row="1"
Grid.Column="1"
Fill="{StaticResource GreenBrush}"
Points="0,1 1,1 1,0"
Stretch="Fill" />
这会产生一个带有直斜边的直角三角形。但是我想要一个弯曲的斜边。使用多边形可以吗?如果不是,我如何实现目标?
上面的 XAML 给出了左手三角形,但我想要一些类似于右手三角形的东西。
我有一种感觉,这可能很简单,但我似乎无法弄清楚
- WPF
- C#
- Visual Studio 2012
最佳答案
问题是因为多边形只允许直线实现曲线效果会很困难
你有两个选择
1)使用Blend创建路径
例如
<Path Data="M0.037120935,318.97711 L3.0000002,319 0,319 z M517,5.0000003 L517,319 3.0000002,319 C286.87436,319 517,178.4174 517,5.0000003 z M517,0 L517,5.0000003 516.89777,0.063097671 z" Fill="#FFFB0404" Stretch="Fill"/>
2)先创建三角形,然后将其斜边与椭圆重叠。
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing" x:Class="WpfApplication1.MainWindow"
Title="MainWindow" Height="350" Width="525">
<Grid x:Name="grid">
<Polygon
Points="0,1 1,1 1,0"
Stretch="Fill" Fill="#FF69FB04" />
<Ellipse Fill="White" HorizontalAlignment="Left" Height="628" Margin="-511,-309,0,0" VerticalAlignment="Top" Width="1028"/>
</Grid>
</Window>
关于c# - 具有弯曲斜边的多边形三角形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30595221/