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

Issue with RadRichTextBox ChangeListStyleCommand

2 Answers 80 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Petter Forss
Top achievements
Rank 1
Petter Forss asked on 09 Dec 2015, 01:43 PM

Hello, We're trying to implement a custom formatting bar for a radrichtextbox and are having some issues with a specific command.

We are tracking the state of the users selected text by adding eventhandlers to the different commands of the radrichtextbox and all is working well, except in one case: The ChangeListStyleCommand. For some reason it seems as if the "ListStyleChangedChanged"-event is not being called when a user selects a segment of text contained (partially or completely) in a list (including an attached image to show what I mean).  

I might have a wrong understanding of how it's supposed to work, but the other commands seem to work in such fashion.

Relevant C# Code:

using System.Windows;
using System.Windows.Controls;
using Telerik.Windows.Controls;
using Telerik.Windows.Documents.Lists;
using Telerik.Windows.Documents.Model;
using Telerik.Windows.Documents.RichTextBoxCommands;
 
namespace ...
{
    public partial class DescriptionEditor : UserControl
    {
        public DescriptionEditor()
        {
            InitializeComponent();
 
            ...
 
            InitializeEventsForTextboxes(PublicDescriptionEditor);           
        }
 
        ...
 
        private void InitializeEventsForTextboxes(params RadRichTextBox[] textboxes)
        {
            if (textboxes != null)
            {
                foreach (var textbox in textboxes)
                {
                    ...
                    // This is performed for the specific textbox.
                    // We know this since other commands are working
                    textbox.Commands.ChangeListStyleCommand.ListStyleChangedChanged += ListStyle_Changed;
                    ...
                }
            }
        }
 
        private void ListStyle_Changed(object sender, StylePropertyChangedEventArgs<ListStyle> e)
        {
            // This never gets called
            ...
        }
    }
}

Relevant XAML code:

<UserControl x:Class="... DescriptionEditor"
    x:Name="PersonDescriptionEditor">
 
    ...
 
    <telerik:RadRichTextBoxx:Name="PublicDescriptionEditor"IsSelectionMiniToolBarEnabled="False" Grid.Row="1"/>
    <telerik:HtmlDataProvider
        Html="{Binding Path=DataContext, ElementName=PersonDescriptionEditor, Mode=TwoWay}"
        RichTextBox="{Binding ElementName=PublicDescriptionEditor}">
        <telerik:HtmlDataProvider.FormatProvider>
            <telerik:HtmlFormatProvider>
                <telerik:HtmlFormatProvider.ExportSettings>
                    <telerik:HtmlExportSettings
                        DocumentExportLevel="Fragment"
                        StylesExportMode="Inline"
                        StyleRepositoryExportMode="DontExportStyles"/>
                </telerik:HtmlFormatProvider.ExportSettings>
            </telerik:HtmlFormatProvider>
        </telerik:HtmlDataProvider.FormatProvider>
    </telerik:HtmlDataProvider>
 
    ...
 
</UserControl>

Not really sure what you need to see, but the above code should contain all relevant parts


 

2 Answers, 1 is accepted

Sort by
0
Accepted
Mihail
Telerik team
answered on 11 Dec 2015, 01:46 PM
Hello Petter,

We have three buttons related to lists. Two of them are toggle buttons, one for bulleted lists and one for numbered lists. Their toggle status will be changed if you click on a paragraph with the corresponding list type. The event used for changing its toggle state is called ToggleStateChanged for ToggleBulletsCommand and ToggleNumberedCommand commands.

The third button is a RadRibbonDropDown that uses a command you are talking about - ChangeListStyleCommand. The drop down contains items for different predefined lists. From what I can see the "ListStyleChangedChanged" event is probably created to provide a mechanism for distinguishing which of the predefined lists is used. This information is needed for implementing a feature for highlighting the currently used predefined list in the drop down. For some reasons this feature is not implemented and as it seems the event is not thrown.
I have logged the problem with the event to our feedback portal as a bug report. Here is a link to the item if you would like to subscribe for status updates: The ListStyleChangedChanged event from ChangeListStyleCommand is never thrown.

There is a possible workaround If you would like to implement such feature. You could create your own command that track the document caret position change. By getting the paragraph list id, you could determine if the used list is different and highlight the required list style.

If you scenario is different or you have further questions do not hesitate to contact us again.

Regards,
Mihail
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Petter Forss
Top achievements
Rank 1
answered on 17 Dec 2015, 10:34 AM

Hello Mihail.

We solved our problem by looking at the "ToggleStateChanged" event on the "ToggleBulletsCommand" and "ToggleNumberedCommand" commands instead. We will initially only allow those two forms of lists anyway. So that should suffice for now :).

 Thank you for your help!


 
 
 
Tags
RichTextBox
Asked by
Petter Forss
Top achievements
Rank 1
Answers by
Mihail
Telerik team
Petter Forss
Top achievements
Rank 1
Share this question
or