通过


Pen.MiterLimit 属性

定义

获取或设置 miter 长度与此笔的 Thickness一半之比的限制。

public:
 property double MiterLimit { double get(); void set(double value); };
public double MiterLimit { get; set; }
member this.MiterLimit : double with get, set
Public Property MiterLimit As Double

属性值

miter 长度与笔的 Thickness一半的比率限制。 此值始终是大于或等于 1 的正数。 默认值为 10.0。

示例

以下示例演示如何使用 MiterLimit 属性来限制由两个线段创建的角的大小。

<Page 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <StackPanel Margin="20">

    <Canvas Margin="100"  Width="100" Height="100">
      <Canvas.Background>
        <DrawingBrush>
          <DrawingBrush.Drawing>
            <GeometryDrawing>
              <GeometryDrawing.Geometry>
                <PathGeometry>
                  <PathGeometry.Figures>
                    <PathFigureCollection>
                      <PathFigure StartPoint="100,50">
                        <PathFigure.Segments>
                          <PathSegmentCollection>
                            <LineSegment Point="200,70" />
                            <LineSegment Point="100,60" />
                          </PathSegmentCollection>
                        </PathFigure.Segments>
                      </PathFigure>
                    </PathFigureCollection>
                  </PathGeometry.Figures>
                </PathGeometry>
              </GeometryDrawing.Geometry>
              <GeometryDrawing.Pen>

                <!-- The MiterLimit is set to a value of 0 so the corner formed
                     by where the two line segments join is cut or blunted. A larger 
                     value would allow for the corner to extend out even beyond 
                     the thickness of the line. -->
                <Pen Brush="Blue" Thickness="4" MiterLimit="0"  />
              </GeometryDrawing.Pen>
            </GeometryDrawing>
          </DrawingBrush.Drawing>
        </DrawingBrush>
      </Canvas.Background>
    </Canvas>

  </StackPanel>

</Page>

下图显示了此代码示例生成的内容。

显示 MiterLimit 示例。角形被剪切。

注解

一个 miter 是一个关节,由斜面中的每两个表面组成一个角。 当两个线段以尖锐的角度相遇时,miter 可能会超出笔划路径的线条的粗细。

Dependency 属性信息

物品 价值
标识符字段 MiterLimitProperty
元数据属性设置为 true 没有

适用于

另请参阅