【问题标题】:Draw circle with point on center - where以点为中心画圆 - 在哪里
【发布时间】:2017-08-14 09:01:49
【问题描述】:

我想在 XAML/WPF 中画一个中心点的圆并使用这样的代码:

        <Ellipse Name="Circle"
            Canvas.Left="4.88"
            Canvas.Top="15.095" 
            Width="9.14"
            Height="9.14"
            Stroke="Red"
            StrokeThickness="0.1" />

        <Ellipse Name="Point"
            Canvas.Left="9.2"
            Canvas.Top="19.415"  
            HorizontalAlignment="Center" 
            VerticalAlignment="Center"
            Width="0.5"
            Height="0.5"
            Fill="Red"
            Stroke="Red"
            StrokeThickness="0.1" />

但是该点不在圆的中心。我哪里做错了?

【问题讨论】:

    标签: wpf xaml draw system.drawing


    【解决方案1】:

    Ellipse 元素未居中。最好使用带有 EllipseGeometry 的 Path 元素:

    <Path Name="Circle" Stroke="Red" StrokeThickness="0.1">
        <Path.Data>
            <EllipseGeometry Center="9.45,19.665" RadiusX="4.57" RadiusY="4.57"/>
        </Path.Data>
    </Path>
    <Path Name="Point" Fill="Red">
        <Path.Data>
            <EllipseGeometry Center="9.45,19.665" RadiusX="0.25" RadiusY="0.25"/>
        </Path.Data>
    </Path>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-03-25
      • 1970-01-01
      • 1970-01-01
      • 2018-07-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多