Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > RibbonBar > Creating a text editor (radribbon control interface) in c# only, not using XAML

Not answered Creating a text editor (radribbon control interface) in c# only, not using XAML

Feed from this thread
  • Aron avatar

    Posted on Jan 20, 2012 (permalink)

    Hi guys.

    I'm a bit of a n00b with Telerik controls, and while I've managed to create a nicely implemented radRichTextBox control dynamically using c# (reads my html data in and displays correctly)  I'm struggling to figure out how to create the toolbar interface for it.

    I'm trying to use RadRibbonBar, RadRibbonTabs, and their associated buttons and controls, but cannot find any examples of how to do this purely programmatically (using c#).

    Can anyone please suggest how to create the buttons, add them to the tabs, and create the tabs and add them to the bar using only c#?

    Many thanks!!!

    Reply

  • Tina Stancheva Tina Stancheva admin's avatar

    Posted on Jan 25, 2012 (permalink)

    Hi Aron,

    If I understand your scenario correctly what you need is the RadRichTextBoxRibbonUI. You can find more information on how to add it to your application here and you can also examine this demo.

    Let us know if you need more info.

    Kind regards,
    Tina Stancheva
    the Telerik team

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

    Reply

  • Aron avatar

    Posted on Jan 25, 2012 (permalink)

    Hi Tina
    I did read that example previously, though thank you for taking the time to send it to me.

    My problem is that the example requires you to drag the control in blend, which then generates the XAML for you.  I don't want to do this I want to define it ALL using C#.
    (I've stripped a bunch of funcitonality out of this, but in general this is what I'm doing... grdEdit is a pre-defined grid)

    RadRichTextBoxRibbonUI editTab = new RadRichTextBoxRibbonUI();

    RadRichTextBox richText = new RadRichTextBox();
    richText.Document.LayoutMode = Telerik.Windows.Documents.Model.DocumentLayoutMode.Flow;
    richText.Height = 300;
    richText.MaxHeight = 300;
    richText.Margin = new Thickness(15, 60, 15, 15);
    richText.VerticalAlignment = System.Windows.VerticalAlignment.Top;
    richText.IsReadOnly = false;

    HtmlDataProvider hdp = new HtmlDataProvider();

    hdp.RichTextBox = richText;

    grdEdit.Height = 400;
    grdEdit.Children.Add(editTab);
    grdEdit.Children.Add(richText);


    Reply

  • Tina Stancheva Tina Stancheva admin's avatar

    Posted on Jan 25, 2012 (permalink)

    Hello Aron,

    I attached a sample code that can get you started. Please have  alook at it and let me know if it helps.

    Greetings,
    Tina Stancheva
    the Telerik team

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

    Reply

  • Aron avatar

    Posted on Jan 26, 2012 (permalink)

    Tina, that is BRILLIANT, thank you!

    One last question if you don't mind.
    Happily adding tabs,groups,buttons and starting to get the interface that I want however I'm having a little issue with the RadRibbonCombo in that I can display it, I can show the content, but I can't get it to affect the selected text.  I'm making the assumption that I've not set the CommandParameter correctly.  Could you give me a pointer?

    RadRibbonComboBox fontCbo = new RadRibbonComboBox
    {
    OpenDropDownOnFocus = true,
    IsReadOnly = true,
    Command = new ChangeFontSizeCommand(richText),
    CommandParameter = "{Binding RelativeSource={RelativeSource Self}, Path=SelectedItem.Tag}",
    Height = 21,
    Width = 45
    };

    RadRibbonComboBoxItem font8 = new RadRibbonComboBoxItem{ Content="8", Tag="10.67" };
    fontCbo.Items.Add(font8);

    fontStack1.Children.Add(fontCbo);
    fontGroup.Items.Add(fontStack1);

    Reply

  • Aron avatar

    Posted on Jan 26, 2012 (permalink)

    Hi Tina

    In the same vein, for something like the font family dropdown, could you please tell me the C# equivalent of the XAML:

    ItemsSource="{Binding Source={StaticResource FontFamiliesProvider}, Path=RegisteredFonts}"

    Many many thanks
    Aron

    Reply

  • Aron avatar

    Posted on Jan 26, 2012 (permalink)

    and the last question today (HONEST!!!)

    Setting the small/large image in C#.
    I'd like to use your standard icons, but looking at the XAML they appear to be a component of the RichTextBoxUI library?

    The XAML reads:
    SmallImage="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/ClearFormatting16.png"

    What would the equivalent C# be, given that I'd want to use the exact same component?
    Many thanks, and I PROMISE no more questions today!

    Aron

    Reply

  • Petar Mladenov Petar Mladenov admin's avatar

    Posted on Jan 31, 2012 (permalink)

    Hi Aron,

     I believe the first two questions could be also told as "How to Set Binding in Code behind?" and this post will help you proceed further.
    On the other hand, setting the SmallImage in code behind could be done like so:

    RadRibbonButton button = new RadRibbonButton();
               button.SmallImage = new BitmapImage(new Uri("/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/ClearFormatting16.png", UriKind.RelativeOrAbsolute));
    Finally, I highly suggest you to use XAML for creating your UI - it will be faster, easy to maintain and to change when you get used to it.

    All the best,
    Petar Mladenov
    the Telerik team

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

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > RibbonBar > Creating a text editor (radribbon control interface) in c# only, not using XAML