wpf - 如何在 XAML 中绘制一个 'felt pen' 样式的圆而不结束连接

标签 wpf xaml

我正在使用 XAML 设计一个 Metro Style 应用程序,我需要在两端没有正确相交的地方画一个圆,就好像它是用红色毡笔涂写的一样。像这样:

enter image description here

这如何在 XAML 中完成?

最佳答案

好的,准备好使用一些 XAML:

<Path Grid.Row="1" Grid.Column="1" Margin="10"              
        Stroke="Red" StrokeThickness="5">
    <Path.Data>
        <PathGeometry>
            <PathGeometry.Figures>
                <PathFigureCollection>
                    <PathFigure IsClosed="False" StartPoint="5,50">
                        <PathFigure.Segments>
                            <PathSegmentCollection>

                                <ArcSegment Point="50,5" Size="80, 40" SweepDirection="Clockwise" />
                                <ArcSegment Point="95,50" Size="50, 50" SweepDirection="Clockwise" />
                                <ArcSegment Point="50,95" Size="50, 50" SweepDirection="Clockwise" />
                                <ArcSegment Point="5,55" Size="55, 100" SweepDirection="Clockwise" />

                            </PathSegmentCollection>
                        </PathFigure.Segments>
                    </PathFigure>
                </PathFigureCollection>
            </PathGeometry.Figures>
        </PathGeometry>
    </Path.Data>
</Path>

此代码产生:

enter image description here

您可以稍微调整坐标以获得更多|更少的四舍五入结果,并且可以使用 BezierSegments。

关于wpf - 如何在 XAML 中绘制一个 'felt pen' 样式的圆而不结束连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12158526/

相关文章:

wpf - 基于祖先类型的存在设置样式

.net - 找不到任何 Caliburn Micro with Prism 的 sample

c# - 从 WinForms 窗体显示 WPF 窗口绝对安全吗?

python - 在 Python 中,如何在使用 WPF 的程序中自动控制 UI?

c# - Silverlight 网格未填满整个空间

xaml - Xamarin.Forms 需要 WrapLayout

c# - 带有 CompositeCollection 的 WPF ComboBox - SelectedIndex 不粘

wpf - 使用 anchor 计算比例

c# - 为什么添加 ContentControl 会导致我的应用程序进入中断模式?

c# - 你如何通过xaml引用一个类?