Table of Contents

Property DefaultMenu

Namespace
Alternet.Editor.Wpf
Assembly
Alternet.Editor.Wpf.v9.dll

DefaultMenu

public ContextMenu DefaultMenu { get; set; }

Property Value

ContextMenu

Examples

Here is how to use a DefaultMenu in the C# code:

public partial class MainWindow : Window
{
    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
        var textEditor = new Alternet.Editor.Wpf.TextEditor();
        textEditor.UseDefaultMenu = true;
        var menuItem = new System.Windows.Controls.MenuItem();
        menuItem.Header = "Custom Action";
        menuItem.Click += DoCustomAction;
        textEditor.DefaultMenu.Items.Add(menuItem);
    }

    protected void DoCustomAction(object sender, System.Windows.RoutedEventArgs e)
    {
        System.Windows.MessageBox.Show("This is a custom action");
    }
}

Here is how to use a DefaultMenu in the Visual Basic code:

Partial Public Class MainWindow

    Private Sub Window_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
        Dim textEditor = New Alternet.Editor.Wpf.TextEditor()
        textEditor.UseDefaultMenu = True
        Dim menuItem = New System.Windows.Controls.MenuItem()
        menuItem.Header = "Custom Action"
        AddHandler menuItem.Click, AddressOf DoCustomAction
        textEditor.DefaultMenu.Items.Add(menuItem)
    End Sub

    Protected Sub DoCustomAction(ByVal sender As Object, ByVal e As System.Windows.RoutedRoutedEventArgs)
        System.Windows.MessageBox.Show("This is a custom action")
    End Sub
End Class

Remarks

TextEditor control uses its context menu with text edit actions, such as cut, copy or paste, unless UseDefaultMenu is set to false.

You can extend DefaultMenu with your own menu items, or set a different ContextMenu to provide a different context menu.