This documentation is archived and is not being maintained.

DrawingAttributes.Width Property

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

Namespace: System.Windows.Ink
Assembly: PresentationCore (in presentationcore.dll)
XML Namespace:

public double Width { get; set; }
/** @property */
public double get_Width ()

/** @property */
public void set_Width (double value)

public function get Width () : double

public function set Width (value : double)

 This property is not typically used in XAML. 

Property Value

The width of the stylus used to draw the Stroke.

Exception typeCondition


The Width property is less than Double.Epsilon or Double.NaN.

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

  • The amount of pressure applied to the stylus when the Stroke is drawn.

  • The value of the StylusTipTransform property.

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

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;

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0