How to access RadRichTextBoxRibbonUI in RadRichTextBox

6 posts, 2 answers
  1. york
    york avatar
    160 posts
    Member since:
    Jul 2012

    Posted 29 Jan 2012 Link to this post

    Hi,
    I have created a RadRichTextBox with RadRichTextBoxRibbonUI  in it, the xaml code is (auto-generated for word processor option),
      <telerik:RadRichTextBox Grid.Row="1" HorizontalAlignment="Stretch" IsContextMenuEnabled="True" IsSelectionMiniToolBarEnabled="True" IsSpellCheckingEnabled="True" LayoutMode="Paged" Name="radRichTextBox1" />
             <telerik:RadRichTextBoxRibbonUI BackstageClippingElement="{Binding ElementName=gridRadRtbParent}" CollapseThresholdSize="50,50" DataContext="{Binding Path=Commands, ElementName=radRichTextBox1}" ApplicationName="Edit Letters">
                            <telerik:RadRichTextBoxRibbonUI.QuickAccessToolBar>
                                <telerik:QuickAccessToolBar>
                                </telerik:QuickAccessToolBar>
                            </telerik:RadRichTextBoxRibbonUI.QuickAccessToolBar>
                            <telerik:RadRibbonTab Header="Home">
                            </telerik:RadRibbonTab>
    ...
    I want to know how to access RadRichTextBoxRibbonUI's ApplicationName field by RadRichTextBox Name: radRichTextBox1 in C# or VB program so that I can change the caption of radRichTextBox1. Also how to create the entire RadRichTextBoxRibbonUI set when creating RadRichTextBox  dynamically in C# or VB.

    Thanks,
    York
  2. Answer
    Boby
    Admin
    Boby avatar
    595 posts

    Posted 01 Feb 2012 Link to this post

    Hello York Zhang,
    To change RadRichTextBoxRibbonUI.ApplicationName property, you should give the component a name in XAML and access it through its name in the code behind.
    You can create RadRichTextBoxRibbonUI dynamically in code-behind - you should just 'translate' the generated XAML code to C# or VB. You can also create a user control containing it and dynamically create and use it.

    All the best,
    Boby
    the Telerik team

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

  3. DevCraft banner
  4. york
    york avatar
    160 posts
    Member since:
    Jul 2012

    Posted 01 Feb 2012 Link to this post

    Thanks Boby. Do you mean that I should add name in RadRichTextBoxRibbonUI like
    <telerik:RadRichTextBoxRibbonUI Name="radRichTextBoxRibbon1" BackstageClippingElement="{Binding ElementName=gridRadRtbParent}" CollapseThresholdSize="50,50" DataContext="{Binding Path=Commands, ElementName=radRichTextBox1}" ApplicationName="Edit Letters">
    Because RadRichTextBoxRibbonUI is created in RadRichTextBox, where is RadRichTextBoxRibbonUI stored in RadRichTextBox in C#/VB?
    Can you give a more detailed code in C#/VB to create dynamically RadRichTextBoxRibbonUI in RadRichTextBox?
  5. Answer
    Boby
    Admin
    Boby avatar
    595 posts

    Posted 06 Feb 2012 Link to this post

    Hello York Zhang,
    RadRichTextBoxRibbonUI is separate, RadRibbonView-derived control that presents an interface for controlling associated instance of RadRichTextBox. The relation between them is realized with a binding with  RadRichTextBoxCommands:
    DataContext="{Binding Path=Commands, ElementName=radRichTextBox1}"
    We don't have sample code for creating RadRichTextBobRibbonUI, but you can write it yourself using the XAML from our online example as a sample (choose Code in the upper right and then TelerikEditorExample.xaml from the tree in the left):
    RadRichTextBoxRibbonUI ribbonUI = new RadRichTextBoxRibbonUI();
     
    ribbonUI.Items.Add(
        new RadRibbonTab()
        {
            Header = "Tab 1"
        });
    and so on.

    Greetings,
    Boby
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  6. DQ
    DQ avatar
    11 posts
    Member since:
    Jul 2012

    Posted 20 Jul 2012 Link to this post

    But, how does one change the behavior of RadRichTextBoxRibbonUI without rewrite the whole thing.  For example, I already have the two classes work well together without writing a lot of code, which is very good.   But, how do I capture and change the default behavior of the save as (or export) to html format.  I don't want to save a bunch of default Html code with font settings, bla bla bla.

    Speaking otherwise, I want to capture the save as/ or export method so that I can change the exporting level.  What even/delegate/ whatsoever I have to do?

    HtmlExportSettings exportSettings = new HtmlExportSettings();
    exportSettings.DocumentExportLevel = DocumentExportLevel.Fragment;
    exportSettings.StylesExportMode = StylesExportMode.Inline;
    HtmlFormatProvider formatProvider = new HtmlFormatProvider();
    formatProvider.ExportSettings = exportSettings;
  7. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 24 Jul 2012 Link to this post

    Hello DQ,

    As mentioned in the Import/Export Settings article, the OpenDocument and SaveCommand do not create a format provider each time they are executed. Instead, they use a "cached" format provider, which you can obtain a reference to in the following way:

    HtmlFormatProvider htmlFormatProvider = DocumentFormatProvidersManager.GetProviderByExtension("html") as HtmlFormatProvider;

    If you set the HtmlExportSettings you have created to this format provider, when you execute the commands from RadRichTextBoxRibbonUI, your settings will be applied.

    I hope this helps.

    All the best,
    Iva Toteva
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
DevCraft banner