• HOME
  • PRODUCTS
  • DEMOS
  • BUY
  • BLOG
  • FORUM
  • DOCUMENTATION
  • ABOUT
  • FREE EVALUATION
Search Results for

    Show / Hide Table of Contents

    DefaultMenu Property

    DefaultMenu

    Declaration
    public ContextMenu DefaultMenu { get; set; }
    Property Value
    Type Description
    ContextMenu
    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.

    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
    
    In This Article
    Back to top Copyright AlterNET Software Download PDF