locked
How to override defualt textbox context menu in windows store c# RRS feed

  • Question

  • Hello,

    How to override default context menu of textbox in windows store app. And is there any way to add some controls in context menu.

    Friday, February 7, 2014 9:38 AM

Answers

  • doesnt look like you can extend the contextmenu but you can override it, Use the ContextMenuOpening event

    private void TextBox_ContextMenuOpening(object sender, ContextMenuEventArgs e)
            {
                e.Handled = true;
    
                Popup f = new Popup();
                f.IsLightDismissEnabled = true;
                f.Child = new Border
                    {
                        Background = new SolidColorBrush(Colors.CadetBlue),
                        Width = 200,
                        Height = 100
                    };
    
                f.VerticalOffset = e.CursorTop;
                f.HorizontalOffset = e.CursorLeft;
    
                f.IsOpen = true;
    
    
              
            }


    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    • Marked as answer by zee_patel Friday, February 7, 2014 11:06 AM
    Friday, February 7, 2014 10:13 AM

All replies

  • doesnt look like you can extend the contextmenu but you can override it, Use the ContextMenuOpening event

    private void TextBox_ContextMenuOpening(object sender, ContextMenuEventArgs e)
            {
                e.Handled = true;
    
                Popup f = new Popup();
                f.IsLightDismissEnabled = true;
                f.Child = new Border
                    {
                        Background = new SolidColorBrush(Colors.CadetBlue),
                        Width = 200,
                        Height = 100
                    };
    
                f.VerticalOffset = e.CursorTop;
                f.HorizontalOffset = e.CursorLeft;
    
                f.IsOpen = true;
    
    
              
            }


    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    • Marked as answer by zee_patel Friday, February 7, 2014 11:06 AM
    Friday, February 7, 2014 10:13 AM
  • Thanks a lot Dave.

    • Edited by zee_patel Friday, February 7, 2014 11:12 AM
    Friday, February 7, 2014 11:08 AM