DesignerCommands Property
DesignerCommands
Represents a collection of standard designer commands like selecting, copying, pasting, moving and resizing controls.
Declaration
public IFormDesignerCommands DesignerCommands { get; }
Property Value
Type | Description |
---|---|
IFormDesignerCommands |
Implements
Remarks
Any standard Form Designer's command can be called directly from code or by pressing a hot key combination. You can programmatically change this combination.
Examples
Here is how to use a DesignerCommands in the C# code:
using System;
using System.Windows;
using System.Windows.Input;
public partial class MainWindow : Window
{
private void Window_Loaded(object sender, RoutedEventArgs e)
{
var formDesigner = new Alternet.FormDesigner.Wpf.FormDesignerControl();
formDesigner.AutoSaveToSource = false;
CommandBinding cmd = null;
for (int i = 0; i < formDesigner.CommandBindings.Count; i++)
{
cmd = formDesigner.CommandBindings[i];
if (cmd.Command == ApplicationCommands.Undo)
{
break;
}
}
if (cmd.Command == ApplicationCommands.Undo)
formDesigner.CommandBindings.Remove(cmd);
formDesigner.AddCommandHandler(ApplicationCommands.Undo, CustomAction);
}
private void CustomAction()
{
MessageBox.Show("Custom command");
}
}
Here is how to use a DesignerCommands in the Visual Basic code:
Imports System
Imports System.Windows
Imports System.Windows.Input
Partial Public Class MainWindow
Inherits Window
Private Sub Window_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
Dim formDesigner = New Alternet.FormDesigner.Wpf.FormDesignerControl()
formDesigner.AutoSaveToSource = False
Dim cmd As CommandBinding = Nothing
For i As Integer = 0 To formDesigner.CommandBindings.Count - 1
cmd = formDesigner.CommandBindings(i)
If cmd.Command = ApplicationCommands.Undo Then
Exit For
End If
Next
If cmd.Command = ApplicationCommands.Undo Then
formDesigner.CommandBindings.Remove(cmd)
End If
formDesigner.AddCommandHandler(ApplicationCommands.Undo, AddressOf CustomAction)
End Sub
Private Sub CustomAction()
MessageBox.Show("Custom command")
End Sub
End Class