Hi,
I've encountered a weird behavior. I am trying to hide certain parts (table and font formatting) of a RadRichTextBox's content menu using the "Use ContextMenuBuilder class" approach of this example: http://www.telerik.com/help/wpf/radrichtextbox-features-context-menu.html
This is the class I created to hide certain parts of the context menu:
And I then set my RichTextBox to use that new Context menu in another class:
This works perfectly if you only have 1 RichTextBox you want to do this on. The problem appears if you want to do this on many RichTextBoxes:
Now, if you right click and paste in rtb1 or rtb2, the text appears in rtb3 (the last RichTextBox for which we assigned the menu). It seems that the 3 menus are pointing to the same instance even though they are all new CustomMenuBuilder objects. Any way of hiding context menu sections and having each menu related to the right RichTextBox?
Thanks,
-- Joel
I've encountered a weird behavior. I am trying to hide certain parts (table and font formatting) of a RadRichTextBox's content menu using the "Use ContextMenuBuilder class" approach of this example: http://www.telerik.com/help/wpf/radrichtextbox-features-context-menu.html
This is the class I created to hide certain parts of the context menu:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Telerik.Windows.Documents.UI.Extensibility;
using Telerik.Windows.Documents.UI;
using Telerik.Windows.Controls.RichTextBoxUI.Menus;
using Telerik.Windows.Documents.Model;
using Telerik.Windows.Controls;
class CustomMenuBuilder : ContextMenuContentBuilder
{
private RadRichTextBox radRichTextBox;
public CustomMenuBuilder(RadRichTextBox radRichTextBox)
: base(radRichTextBox)
{
this.radRichTextBox = radRichTextBox;
}
protected override ContextMenuGroup CreateTableCommands()
{
ContextMenuGroup g = new ContextMenuGroup();
return g;
}
protected override ContextMenuGroup CreateHyperlinkCommands(bool forExistingHyperlink)
{
ContextMenuGroup g = new ContextMenuGroup();
return g;
}
protected override ContextMenuGroup CreateTextEditCommands()
{
ContextMenuGroup g = new ContextMenuGroup();
return g;
}
}
And I then set my RichTextBox to use that new Context menu in another class:
((Telerik.Windows.Controls.RichTextBoxUI.ContextMenu)rtb1.ContextMenu).ContentBuilder = new CustomMenuBuilder(rtb1);
This works perfectly if you only have 1 RichTextBox you want to do this on. The problem appears if you want to do this on many RichTextBoxes:
((Telerik.Windows.Controls.RichTextBoxUI.ContextMenu)rtb1.ContextMenu).ContentBuilder = new CustomMenuBuilder(rtb1);
((Telerik.Windows.Controls.RichTextBoxUI.ContextMenu)rtb2.ContextMenu).ContentBuilder = new CustomMenuBuilder(rtb2);
((Telerik.Windows.Controls.RichTextBoxUI.ContextMenu)rtb3.ContextMenu).ContentBuilder = new CustomMenuBuilder(rtb3);
Now, if you right click and paste in rtb1 or rtb2, the text appears in rtb3 (the last RichTextBox for which we assigned the menu). It seems that the 3 menus are pointing to the same instance even though they are all new CustomMenuBuilder objects. Any way of hiding context menu sections and having each menu related to the right RichTextBox?
Thanks,
-- Joel