One Ribbon Two RichTextBoxes

6 posts, 0 answers
  1. Greg Gum
    Greg Gum avatar
    18 posts
    Member since:
    Jun 2009

    Posted 13 Jan 2012 Link to this post

    I have an app which has two rich textboxes.  They are both visible at the same time on a page. At the top, there is a RibbonBar with the usual RTB controls.  I can wire this up to one RTB, and the ribbonview works fine with it.  However, I need it to work with both of the RTB's, as the user could be adding text to either of them.

    The binding looks like this:
    DataContext="{Binding ElementName=DataFormAlpha, Path=PART_NotesRichTextBox_PerEntity}" 

    But I do not see a way to bind to both of the RTB's.

    Any suggestions would be appreciated.

    Greg
  2. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 17 Jan 2012 Link to this post

    Hi Greg,

    RadRichTextBoxRibbonUI can be used with one RadRichTextBox at a time.
    What you can do, is to handle the GotFocus event of both RadRichTextBoxes and change the DataContext of the RibbonUI to the Commands property of the focused rich text box like this:

    private void radRichTextBox_GotFocus(object sender, RoutedEventArgs e)
    {
        this.radRichTextBoxRibbonUI1.DataContext = ((RadRichTextBox)sender).Commands;
    }

    Regards,
    Iva Toteva
    the Telerik team

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

  3. DevCraft banner
  4. Michele
    Michele avatar
    7 posts
    Member since:
    Jan 2012

    Posted 20 Jan 2012 Link to this post

    Hello Iva,
    I've tried the solution you've suggested, using a unique RadRichtextBoxRibbonUI activating its DataContext on the GotFocus event of the both the two RadRichTextBox controls but it happens nothing...
    Do the RadRichtextBoxRibbonUI or the various RadRichTextBox controls need some particular declaration o attributes to work as you have suggested?
    Please, could you publish a small project showing this behavior?
    Thanks a lot.
    Michele
  5. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 20 Jan 2012 Link to this post

    Hi Michele,

    Perhaps you have forgotten to remove the binding of the DataContext in XAML.
    Anyhow, please find attached the demo you requested. 

    All the best,
    Iva Toteva
    the Telerik team

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

  6. Michael
    Michael avatar
    41 posts
    Member since:
    Oct 2010

    Posted 10 Aug 2013 Link to this post

    Hello,

    Would you be able to extend this example with Mail Merge functionality?

    I have 2 RadRichTextBoxes with one RadRichtextBoxRibbonUI. I've implemented GotFocus event as you have suggested.  It works great.  Where ever my focus is, I can use ribbon bar items to manipulate it (fonts, colors, etc...).  In addition to this, I am using Mail Merge.  Both richtextboxes are binded to the same list.  If I have focus in RichTextbox 1, then I can iterate through the list, but fields in RichTextBox 2 are not changed (understandable).

    Can you suggest how to overwrite MailMerge functions so that I can make changes on both RadRichTextBoxes at the same time?
  7. Boby
    Admin
    Boby avatar
    595 posts

    Posted 14 Aug 2013 Link to this post

    Hi Michael,
    As it seems our are scattered between two forum threads, I would suggest to continue our conversation in the other thread you started on the matter.

    Regards,
    Boby
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    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 >>
Back to Top
DevCraft banner