Issue with RadRichTextBox ChangeListStyleCommand

3 posts, 1 answers
  1. Petter Forss
    Petter Forss avatar
    20 posts
    Member since:
    Oct 2009

    Posted 09 Dec 2015 Link to this post

    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. Answer
    Mihail
    Admin
    Mihail avatar
    192 posts

    Posted 11 Dec 2015 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Petter Forss
    Petter Forss avatar
    20 posts
    Member since:
    Oct 2009

    Posted 17 Dec 2015 in reply to Mihail Link to this post

    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!


     
     
     
Back to Top