RichTextBox Context Menu

5 posts, 1 answers
  1. Cuthahotha
    Cuthahotha avatar
    81 posts
    Member since:
    Sep 2008

    Posted 30 Nov 2010 Link to this post

    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

  2. Answer
    Boby
    Admin
    Boby avatar
    595 posts

    Posted 30 Nov 2010 Link to this post

    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
  3. DevCraft banner
  4. Steve Moss
    Steve Moss avatar
    6 posts
    Member since:
    Oct 2009

    Posted 30 Nov 2010 Link to this post

    EXCELLENT! 

    Thanks,
    Steve
  5. Edward
    Edward avatar
    83 posts
    Member since:
    Feb 2011

    Posted 23 Apr 2012 Link to this post

    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?
  6. Boby
    Admin
    Boby avatar
    595 posts

    Posted 24 Apr 2012 Link to this post

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

Back to Top
DevCraft banner