Enum遍历
private void Window_Loaded(object sender, RoutedEventArgs e)
{
foreach (InkCanvasEditingMode mode in Enum.GetValues(typeof(InkCanvasEditingMode)))
{
this.Editermod.Items.Add(mode);
}
Editermod.SelectedIndex = 0;
}
private void Editermod_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
InkCanvas1.EditingMode = (InkCanvasEditingMode)Editermod.SelectedItem;
}
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="35"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<StackPanel>
<ComboBox Name="Editermod" Margin="5" Panel.ZIndex="23" SelectionChanged="Editermod_SelectionChanged"></ComboBox>
</StackPanel>
<InkCanvas EditingMode="None" Grid.Row="1" Name="InkCanvas1" Background="#FFF7C6C6">
<Button InkCanvas.Right="20" InkCanvas.Bottom="10" Content="清空" Padding="10,2" Click="Button_Click"/>
</InkCanvas>
</Grid>