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

How to access RadRichTextBoxRibbonUI in RadRichTextBox

5 Answers 336 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.
york
Top achievements
Rank 1
york asked on 29 Jan 2012, 11:34 PM
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

5 Answers, 1 is accepted

Sort by
0
Accepted
Boby
Telerik team
answered on 01 Feb 2012, 08:49 AM
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 >>

0
york
Top achievements
Rank 1
answered on 01 Feb 2012, 10:11 PM
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?
0
Accepted
Boby
Telerik team
answered on 06 Feb 2012, 09:24 AM
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 >>
0
DQ
Top achievements
Rank 1
answered on 20 Jul 2012, 06:03 PM
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;
0
Iva Toteva
Telerik team
answered on 24 Jul 2012, 12:33 PM
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.

Tags
RichTextBox
Asked by
york
Top achievements
Rank 1
Answers by
Boby
Telerik team
york
Top achievements
Rank 1
DQ
Top achievements
Rank 1
Iva Toteva
Telerik team
Share this question
or