#486 – InkCanvas Supports Different Editing Modes
February 2, 2012 Leave a comment
The InkCanvas control has an EditingMode property that allows you to change how you interact with the InkCanvas. You can draw on it, select strokes that you’ve already drawn, or erase strokes.
EditingMode can take on one of the following values:
- None – You can’t drawn on the InkCanvas at all
- Ink – You can draw strokes, using a mouse or stylus
- GestureOnly – Responds to gestures, does not allow drawing
- InkAndGesture – Responds to gestures, or allows drawing
- Select – You can select elements that you previously drew
- EraseByPoint – You can use the mouse or stylus as an eraser
- EraseByStroke – You can erase entire strokes by clicking on them
<Window.Resources> <ObjectDataProvider x:Key="editingModes" MethodName="GetValues" ObjectType="{x:Type sys:Enum}"> <ObjectDataProvider.MethodParameters> <x:Type TypeName="controls:InkCanvasEditingMode"/> </ObjectDataProvider.MethodParameters> </ObjectDataProvider> </Window.Resources> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <Border Grid.Column="0" BorderThickness="2" BorderBrush="DodgerBlue" Margin="5" > <InkCanvas MinHeight="0" MinWidth="0" EditingMode="{Binding ElementName=cboEditingMode, Path=SelectedValue}"/> </Border> <ComboBox Grid.Column="1" Name="cboEditingMode" Width="100" Height="25" Margin="5" ItemsSource="{Binding Source={StaticResource editingModes}}"/> </Grid>