Redigera

Dela via


DrawingAttributes.Width Property

Definition

Gets or sets the width of the stylus used to draw the Stroke.

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

Property Value

The width of the stylus used to draw the Stroke.

Exceptions

The Width property is less than Epsilon or NaN.

Examples

The following example demonstrates how to set the Width property. The example assumes that your application has an InkCanvas called inkCanvas1, and two DrawingAttributes objects called inkDA and highlighterDA. For the complete example, see the DrawingAttributes class overview.

// Set up the DrawingAttributes for the pen.
inkDA = new DrawingAttributes();
inkDA.Color = Colors.SpringGreen;
inkDA.Height = 5;
inkDA.Width = 5;
inkDA.FitToCurve = false;
inkDA.StylusTipTransform = new Matrix(1, 0, 0, 5, 0, 0);

// Set up the DrawingAttributes for the highlighter.
highlighterDA = new DrawingAttributes();
highlighterDA.Color = Colors.Orchid;
highlighterDA.IsHighlighter = true;
highlighterDA.IgnorePressure = true;
highlighterDA.StylusTip = StylusTip.Rectangle;
highlighterDA.Height = 30;
highlighterDA.Width = 10;

inkCanvas1.DefaultDrawingAttributes = inkDA;
' Set up the DrawingAttributes for the pen.
inkDA = New Ink.DrawingAttributes()
With inkDA
    .Color = Colors.SpringGreen
    .Height = 5
    .Width = 5
    .FitToCurve = True
    .StylusTipTransform = New Matrix(1, 0, 0, 1, 20, 0)
End With

' Set up the DrawingAttributes for the highlighter.
highlighterDA = New Ink.DrawingAttributes()
With highlighterDA
    .Color = Colors.Orchid
    .IsHighlighter = True
    .IgnorePressure = True
    .StylusTip = StylusTip.Rectangle
    .Height = 30
    .Width = 10
End With

inkCanvas1.DefaultDrawingAttributes = inkDA

Remarks

The following factors affect the height and width of a Stroke when it is rendered, but not the value of the Width property.

If you set the Width property to 0 device independent pixels (DIP), it is changed to 2 DIP.

XAML Text Usage

This property is not typically used in XAML.

Applies to