如何解决如何在UWP中使Region内的PATH可点击
您好,我有一个用例,我需要绘制一个复杂的形状(此处为演示用半圆),这是我使用PATH Uwp类完成的,现在我需要在PATH区域内创建clickable(即用户应该能够单击使用PATH绘制的形状的覆盖区域)。这是XAML,任何人都有一个想法如何实现,然后请分享,将对您有所帮助。谢谢
<Canvas Width="300" Height="300" Background="DarkGray">
<Path Stroke="Black" Fill="Purple" StrokeThickness="4" >
<Path.Data>
<PathGeometry>
<PathGeometry.Figures>
<PathFigure StartPoint="0,100">
<PathFigure.Segments>
<ArcSegment x:Name="UpperArcSegment"
IsLargeArc="True"
Size="20,20"
SweepDirection="Clockwise"
Point="200,100" />
</PathFigure.Segments>
</PathFigure>
</PathGeometry.Figures>
</PathGeometry>
</Path.Data>
</Path>
</Canvas>
解决方法
我可以使用按钮控件中的换行内容来做到这一点,那么任何人都有更好的方法,请分享。这只会使“路径部分”可点击。请确保将“路径填充属性”设置为任何颜色或透明
<Canvas Width="300" Height="300" Background="DarkGray">
<Button Click="Button_Click" x:Name="btnUpper">
<Button.Template >
<ControlTemplate TargetType="Button">
<Path Stroke="Black" Fill="Purple" StrokeThickness="4">
<Path.Data>
<PathGeometry>
<PathGeometry.Figures>
<PathFigure x:Name="UpperArcFigure" StartPoint="0,100">
<PathFigure.Segments>
<ArcSegment x:Name="UpperArcSegment"
IsLargeArc="True"
Size="20,20"
SweepDirection="Clockwise"
Point="200,100" />
</PathFigure.Segments>
</PathFigure>
</PathGeometry.Figures>
</PathGeometry>
</Path.Data>
</Path>
</ControlTemplate>
</Button.Template>
</Button>
</Canvas>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。