Hi
I want to customize the popup menu of a radrichtextbox with new sub item
I use the ContextMenuContentBuilder like this :
Then i use this custom builder like this when i instanciate my richtextbox :
If i use ContextMenuGroup.Add , it's ok, but i want my item to be the first of the popup menu.
If i use ContextMenuGroup.Insert , i got a stack-overflow
Is it a bug or is it me who don't use the component properly ?
I want to customize the popup menu of a radrichtextbox with new sub item
I use the ContextMenuContentBuilder like this :
internal class CustomMenuBuilder : ContextMenuContentBuilder, IDisposable { private RadMenuItem InsertHyperLink; private MyCustomRichTextBox richTextBox; public CustomMenuBuilder(MyCustomRichTextBox richTextBox) : base(richTextBox) { this.richTextBox = richTextBox; InsertHyperLink= new RadMenuItem { Header = CultureTasks.GetUIString("Infologic.Composite.Views.ILEditeur.CustomMenuBuilder.Message01", "Insert hyperlink"), Icon = new Image() { Source = new BitmapImage(new Uri("pack://application:,,,/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/Inserthyperlink.png")) } }; InsertHyperLink.Tag = richTextBox; InsertHyperLink.Click += InsertHyperlink_Click; } void InsertHyperlink_Click(object sender, Telerik.Windows.RadRoutedEventArgs e) { this.richTextBox.MyInsertHyperlink(); } protected override ContextMenuGroup CreateFieldCommands() { return null; } protected override ContextMenuGroup CreateHyperlinkCommands(bool forExistingHyperlink) { return null; } protected override ContextMenuGroup CreateTextEditCommands() { var commands = base.CreateTextEditCommands(); commands.Add(InsertHyperLink); // OK //commands.Insert(0, InsertHyperLink); // KO -> stack overflow return commands; } public void Dispose() { InsertHyperLink.Click -= InsertHyperlink_Click; InsertHyperLink= null; richTextBox = null; } }Then i use this custom builder like this when i instanciate my richtextbox :
var richTextControl = new MyCustomRichTextBox { Name = string.Format("rtb{0}", increment), AcceptsTab = false, LayoutMode = DocumentLayoutMode.Flow, IsSelectionMiniToolBarEnabled = false, DocumentInheritsDefaultStyleSettings = true, FontFamily = fontFamily, ShowMergeFieldsHighlight = true, FontSize = fontSize, HorizontalScrollBarVisibility = ScrollBarVisibility.Auto };var builder = new CustomMenuBuilder(richTextControl);richTextControl.ContextMenu = new Telerik.Windows.Controls.RichTextBoxUI.ContextMenu();((Telerik.Windows.Controls.RichTextBoxUI.ContextMenu)richTextControl.ContextMenu).ContentBuilder = builder;If i use ContextMenuGroup.Add , it's ok, but i want my item to be the first of the popup menu.
If i use ContextMenuGroup.Insert , i got a stack-overflow
Is it a bug or is it me who don't use the component properly ?