ContextMenuGroup.Insert -> stack overflow

2 posts, 0 answers
  1. Thomas
    Thomas avatar
    1 posts
    Member since:
    Dec 2013

    Posted 17 Dec 2013 Link to this post


    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)
            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 ?

  2. Petya
    Petya avatar
    973 posts

    Posted 20 Dec 2013 Link to this post


    Thank you for bringing this issue to our attention!

    I confirmed the problem and we will resolve it as soon as possible. The fix will most likely be included in next LIB, as well as in our next official release. I also added some Telerik points to your account in appreciation of the report.

    Let me know if I can assist you with anything else.

    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. DevCraft R3 2016 release webinar banner
Back to Top