#487 – Specify DrawingAttributes When Drawing to an InkCanvas
February 3, 2012 1 Comment
You can specify a number of different drawing attributes that affect how new strokes appear when drawing on an InkCanvas control. You set the DefaultDrawingAttributes property of the InkCanvas to an instance of the DrawingAttributes class, which contains properties that you can set to change how new strokes appear.
Properties of DrawingAttributes include:
- Color – the color of the new stroke
- Height – height of the brush used to draw a stroke
- Width – width of the brush used to draw a stroke
- FitToCurve – if true, smooths out the stroke
- IsHighlighter – if true, stroke is somewhat translucent, simulating a highlighter
<InkCanvas Name="ink" MinHeight="0" MinWidth="0"> <InkCanvas.DefaultDrawingAttributes> <DrawingAttributes Color="DarkGreen" Width="5" Height="20" FitToCurve="True" IsHighlighter="False" /> </InkCanvas.DefaultDrawingAttributes> <Label Content="Drawing using a dark green stroke, 5x20"/> </InkCanvas>
Here are some examples of different values for Color, Width and Height.
Here is an example of setting the IsHighlighter property to true.