Edit Commands in WPF Syntax Editor
18 Dec 2019 / 1 minute to read
Essential edit for WPF contains built-in RoutedUICommands for all editing and file operations such as select all, cut, copy, paste, new, open, save, save as and so on. The built-in RoutedUICommands can be bound to the edit control by using the Command property of the external controls such as button, menu item, and so on. The following lines of code can be used to bind the RoutedUICommands with external controls.
<Menu BorderBrush="LightGray" BorderThickness="0,0,1,2" Grid.ColumnSpan="1">
<MenuItem Header="_File" Background="Transparent" Width="{Binding}" >
<MenuItem Command="{x:Static sfedit:EditCommands.New}" CommandTarget="{Binding ElementName=Edit1}"/>
<MenuItem Command="{x:Static sfedit:EditCommands.Open}" CommandTarget="{Binding ElementName=Edit1}"/>
<MenuItem Command="{x:Static sfedit:EditCommands.Save}" CommandTarget="{Binding ElementName=Edit1}"/>
<MenuItem Command="{x:Static sfedit:EditCommands.SaveAs}" CommandTarget="{Binding ElementName=Edit1}"/>
</MenuItem>
</Menu>
<Border BorderThickness="1" BorderBrush="Gray" Grid.Row="1" Grid.ColumnSpan="2">
<sfedit:EditControl Name="Edit1" EnableOutlining="False" Background="white" AllowDrop="True" BorderBrush="Black" BorderThickness="0" Margin="0" ShowLineNumber="True"
Grid.Row="1" >
</sfedit:EditControl>
</Border>
The following image displays Open edit command window.
Was this page helpful?
Yes
No
Thank you for your feedback!
Thank you for your feedback and comments. We will rectify this as soon as possible!
An unknown error has occurred. Please try again.
Help us improve this page