RadRichTextbox with RadRichTextBoxRibbonUI in Prism

3 Answers 96 Views
RibbonView and RibbonWindow RichTextBox
Yonggu Kang
Top achievements
Rank 1
Iron
Yonggu Kang asked on 14 Aug 2021, 06:12 PM | edited on 14 Aug 2021, 06:12 PM

 

Hi, Telerik,

I am developing for WPF Prism application on .Net 5.

I need to provide an editor functionality which is in MS Word.

I found Perlom's question here and have read it but, I can't have any clue.

How can I solve this problem?

For your information, I am going to attach an image file captured  Perlom's question.

 

TIA

Kang

 

3 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 18 Aug 2021, 09:59 PM

Hello Kang,

Perlom was planning to split the ribbon UI and RadRichTextBox into two different components and he was concerned about the dependencies between these controls. RadRichTextBox operates independently from its ribbon counterpart, while the ribbon depends on RadRichTextBox in order to load the proper set of commands. Such setup would require that the RadRichTextBox instance should be passed to the ribbon container through some inter-container communication approach. Then it should be assigned as a DataContext, in order to associate the ribbon with it:

<telerik:RadRichTextBoxRibbonUI DataContext="{Binding Commands, ElementName=radRichTextBox}" . . .

The following article about cross-component communication illustrates several approaches for achieving this goal. You can pick the one that best suits your design.

Also, RadRichTextBox follows a significantly different set of concepts from the standard data-bound controls as it operates with documents instead of business objects. Still, if you need to use it in an MVVM scenario, where the document contents should be exposed through a view model, you can consider the usage of DataProviders, which are thoroughly explained in the following article - DataProviders.

I believe that Perlom's inquiry was rather specific to his setup, so you might not need to tackle the same problem depending on what design you choose to follow. I would suggest that you try with a simple Spike and check how things turn out on your side. Feel free to drop a line to share your progress or discuss any problems that you encountered. 

Regards,
Ivan Ivanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Yonggu Kang
Top achievements
Rank 1
Iron
commented on 19 Aug 2021, 10:39 AM | edited

Hi.

First of all, thanks for the reply.

As you know, I would like to implement an editor functionality. I think that is what Perlom was going to do.

Below is the problem I have.

RadRichTextBoxRibbonUI is In MainShell.xaml and it has two Regions, RibbonRegion and RibbonRegion.
RadRichTextBox is in ViewA.xaml which is in ModuleA, a different module and RadRibbonTab is in ViewATab.xaml in ModuleA.

In OnInitialized of the ModuleA, I request navigate to ViewA.
I have DependentViewRegionBehavior class to add dependent views to regions which I want.
I add the RegionBehavior for it.
Therefore, when adding ViewA to ContentRegion, ViewATab also add to RibbonRegion.

I have ISupportRichTextBox interface which I write and ViewA and ViewATab implement it.
So ViewATab knows RadRichTextBox.

In this situation, How can I set DataContext of RadRichTextBoxRibbonUI to the RadRichTextBox?

Just in case, I am going to attach my source.

 

Kang

0
Ivan Ivanov
Telerik team
answered on 24 Aug 2021, 09:02 AM

Hello Kang,

I fetched the attached project and had a brief overview. However, I will have to test some ideas in practice to check whether they should be viable. I will do my best to drop a line with my observations by the end of the week.

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Yonggu Kang
Top achievements
Rank 1
Iron
commented on 24 Aug 2021, 04:59 PM

Hi, Ivan.

It's great.
In the meantime, I've been waiting for a long time.

I want to hear the good news from you.

 

 

0
Vladislav
Telerik team
answered on 27 Aug 2021, 08:10 AM

Hello Kang,

Ivan is out of the office today, so I will assist you.

I have observed the attached project and have modified it to bind the RibbonUI to the RichTextBox. I set the ribbon's DataContext, to the RichTextBox's Commands property inside the DependentViewRegionBehavior class. I have attached the modified project for reference.

And here is only the modified part inside the ActiveViews_CollectionChanged() method inside DependentViewRegionBehavior class:

...
var dependentViewInfo = CreateDependentViewInfo(attribute);

if (newView is ISupportRichTextBox newViewRichTextBox)
{
    if (dependentViewInfo.View is ISupportRichTextBox dependentViewInfoRichTextBox)
    {
        dependentViewInfoRichTextBox.RadRichTextBox = newViewRichTextBox.RadRichTextBox;
    }

    if (dependentViewInfo.View is ISupportDataContext dependentViewInfoDC)
    {
        dependentViewInfoDC.DataContext = newViewRichTextBox.RadRichTextBox.Commands;
    }
}

dependentViews.Add(dependentViewInfo);
...

I hope this solves your issue.

Regards,
Vladislav
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
RibbonView and RibbonWindow RichTextBox
Asked by
Yonggu Kang
Top achievements
Rank 1
Iron
Answers by
Ivan Ivanov
Telerik team
Vladislav
Telerik team
Share this question
or