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

RichTextBox Context Menu

4 Answers 223 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Cuthahotha
Top achievements
Rank 1
Cuthahotha asked on 30 Nov 2010, 03:26 PM
Is it possible to add an item to a rich text box context menu?  I would like to test to see that a word is selected, then add to the context menu a "Add Keyword" menu item.

Thanks,
Steve

4 Answers, 1 is accepted

Sort by
0
Accepted
Boby
Telerik team
answered on 30 Nov 2010, 04:43 PM
Hi Cuthahotha,
Take a look at our blog post about customizing RadRichTextBox's context menu and selection mini toolbar.

All the best,
Boby
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Steve Moss
Top achievements
Rank 1
answered on 30 Nov 2010, 04:52 PM
EXCELLENT! 

Thanks,
Steve
0
Edward
Top achievements
Rank 1
answered on 23 Apr 2012, 09:10 PM
I was using that Showing event handler, and noticed that a richtextbox declared in one page can access the same context menu as another richtextbox in another page?
0
Boby
Telerik team
answered on 24 Apr 2012, 09:11 AM
Hello Edward,
The behavior you are observing is caused by the fact that MEF caches ContextMenu instances and reuse them for satisfying the imports of all RadRichTextBoxes - actually all RadRichTextBox instances uses the same context menu. You have two options:
  • manually set different instances of ContextMenu to all your RadRichTextBox-es
    this.radRichTextBox.ContextMenu = new Telerik.Windows.Controls.RichTextBoxUI.ContextMenu();
  • Create custom context menu that will be non-sharable. MEF will automatically load different instances of it for all RadRichTextBoxes on demand:
    [PartCreationPolicy(CreationPolicy.NonShared)]
    [CustomContextMenu]
    public class NonSharedContextMenu : ContextMenu
    {
    }

Don't hesitate to contact us if you have other questions.


Kind regards,
Boby
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
RichTextBox
Asked by
Cuthahotha
Top achievements
Rank 1
Answers by
Boby
Telerik team
Steve Moss
Top achievements
Rank 1
Edward
Top achievements
Rank 1
Share this question
or