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

Change format without selection

3 Answers 98 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 26 Nov 2013, 04:21 PM
I have a simple UserControl including a RadRichTextBox and 3 basic format buttons (bold, italic, underline) which work by applying
ToggleBold and the like. It is pretty much the same as this example, upon which it is based.
http://www.telerik.com/community/forums/wpf/richtextbox/bold-italic-underline-togglebuttons.aspx

It works fine as far as formatting a selection is concerned. Or formatting a word in which the caret is placed.

But the problem is that it is not able to change the format setting without a selection, and then applying it on the next typed text. That is a pretty common scenario. It also does work in the example below, albeit that a ribbon is used there.
http://demos.telerik.com/silverlight/#RichTextBox/TelerikEditor

I also noticed that my caret position is no longer shown when moving the pointer to a button.

I have tried a couple of things using InsertFragment, as seems to be suggested in the documentation below. But that lead me nowhere.
http://www.telerik.com/help/silverlight/radrichtextbox-features-formatting-api.html

So my questions are:
- It is possible what I want?
- How do I achieve that?



3 Answers, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 28 Nov 2013, 04:50 PM
Hello,

Could you please check the following video I made of the online demo and let me know if this is what you are trying to achieve: http://screencast.com/t/mMY88JJz? We'd also appreciate some additional details on the steps you are executing that are preventing you from inserting rich-text in RadRichTextBox.

Looking forward to your reply.

Regards,
Petya
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 >>
0
Robert
Top achievements
Rank 1
answered on 02 Dec 2013, 03:16 PM
Hi Petya,

Thanks for your reply. I have just returned from a brief holiday, and looked into it again today.

Your video indeed is what I wanted to achieve, but without the ribbon.

Meanwhile I have solved the problem myself. The solution surprised me. There probably were some other issues in my code too. But key was a slight difference between 2 approaches that were both described by Telerik, but of which only one worked. The malfunctioning one may be a bug.

I had something very similar as I found here, using the Click event.
       http://www.telerik.com/help/wpf/radrichtextbox-getting-started.html
So in my code:
       <ToggleButton Content="B" x:Name="boldButton" Click="BoldButton_Click" FontWeight="Bold"/>
With:
        private void BoldButton_Click(object sender, RoutedEventArgs e)
        {
            radRichTextBox.ToggleBold();
        }
But the problem was that when pressing the button the caret got lost. When clicking again on the intended edit location in the RadRichTextBox, the bold-toggle picked up the local setting again, usually switching back to non bold.

The approach that turned out to work was like I found here, using a Command binding:
       http://www.telerik.com/community/forums/silverlight/richtextbox/toggle-button-synchronized-with-the-editor.aspx
So in my code:
       <ToggleButton Content="B" x:Name="boldButton" Command="{Binding ElementName=radRichTextBox, Path=ToggleBoldCommand}"  FontWeight="Bold"/>
Now the caret stayed in place and behaviour of the bold formatting was as desired.

The first approach may be an issue Telerik has to look into.

If I have overlooked something, please let me know.
0
Petya
Telerik team
answered on 05 Dec 2013, 01:05 PM
Hi,

Thank you for getting back to us!

You are right that when the focus of the control is lost the issue observed by you is present. Using the command should resolve this, as well as replacing the ToggleButton with RadRibbonToggleButton or forcing the focus back in the control. We will make sure to update the documentation on the matter respectively as well.

Let us know if you encounter any other issues!

Regards,
Petya
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 >>
Tags
RichTextBox
Asked by
Robert
Top achievements
Rank 1
Answers by
Petya
Telerik team
Robert
Top achievements
Rank 1
Share this question
or