#481 – You Can Draw On an InkCanvas Control with the Mouse

You can use the InkCanvas control to include an area of your user interface that users can draw on, using the mouse or a stylus.

By default, an InkCanvas allows drawing on its surface using the mouse.  Each time that you click and drag with the mouse, you are creating a stroke, which is then stored with the InkCanvas.

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <Label Grid.Row="0" Content="Draw in the area below using your mouse" Margin="10,5"/>
        <Border Grid.Row="1" BorderBrush="DodgerBlue" BorderThickness="2" Margin="10" SnapsToDevicePixels="True">
            <InkCanvas/>
        </Border>
    </Grid>

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

2 Responses to #481 – You Can Draw On an InkCanvas Control with the Mouse

  1. Pingback: Dew Drop – January 26, 2012 (#1,251) | Alvin Ashcraft's Morning Dew

  2. Pingback: #482 – You Can Include Other Controls Inside an InkCanvas « 2,000 Things You Should Know About WPF

Leave a comment