This is a migrated thread and some comments may be shown as answers.

ContextMenuGroup.Insert -> stack overflow

1 Answer 17 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 17 Dec 2013, 03:25 PM
Hi

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 ?

1 Answer, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 20 Dec 2013, 02:12 PM
Hi,

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.

Regards,
Petya
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
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 >>
Tags
Menu
Asked by
Thomas
Top achievements
Rank 1
Answers by
Petya
Telerik team
Share this question
or