wpf - Replace RichTextBox's ContextMenu -


Using .NET 4 and VS2010 Pro, I have created a very simple WPF application, in which the main XW contains the following XAML:

& lt; Grid & gt; & Lt; RichTextBox x: name = "rich textbox" margin = "2" /> & Lt; / Grid & gt;

All I want to do, and have failed to do so by now, the context menu for the richxbox is to take my own place. I've tried code-behind without any luck:

public
{MainWindow} {InitializeComponent (); RichTextBox.ContextMenuOpening + = New ReferenceManageHandler (Rich TextboxContactsMenuoping); } Private Zero Rich TextBox_ContextMenuOpening (Object Sender, ContextMenuEventArgs E) {RichTextBox RTB = Sender as Rich Textbox; If (RTB == tap) {return; } ContextMenu contextMenu = rtb.ContextMenu; ContextMenu.Items.Clear (); Menuimemail = new menu item (); MenuItem.Header = "test"; ContextMenu.Items.Add (MENUITEM); ContextMenu.PlacementTarget = rtb; ContextMenu.Placement = PlacementMode. Relative point; Text pointer status = RTB Selection. the ending; If (condition == blank) {return; } Shape positioning = position GETCharacterRect (LogicalDirection.Forward); ContextMenu.HorizontalOffset = positionRect.X; ContextMenu.VerticalOffset = positionRect.Y; ContextMenu.IsOpen = True; E.Handled = True; }

The harm I am doing is not doing properly. Is its mouse mode being caught by event RTB? Do I have to get my own version of RTB and open the context menu to work it out? It really looks like something, but I'm not seeing it.

Thanks in advance. Rich Textbox X: "Rich Textbox" margin = "2" & gt; ">

& lt; RichTextBox.ContextMenu> & lt; ContextMenu / & gt; & lt; /RichTextBox.ContextMenu> & lt; / RichTextBox & gt;

Rich There is a logic for supplying the contextual menu with things like the base class of the textbox, the logic and the paste in the textboxbox. This logic handles handled as ContextMenuOpening, so your handler has not been implemented. Scope The RichTextBox even empty Info menu, it will leave alone your context menu and open your handler.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -