RadRichTextBox Conditional Formatting

2 posts, 0 answers
  1. Pratham
    Pratham avatar
    2 posts
    Member since:
    Nov 2014

    Posted 06 Nov 2014 Link to this post

    Hi,
     
    I have RadRichTextBox on my WPF Window. I am using MVVM design pattern and have binding in my View for this RadRichTextBox using TxtDataProvider as below:

    <Window.DataContext>
            <local:vmRichTextBox />
        </Window.DataContext>
        <Grid>
            <telerik:RadRichTextBox x:Name="rchTextBox" Width="210" Height="150">
            </telerik:RadRichTextBox>
            <telerik:TxtDataProvider RichTextBox="{Binding ElementName= rchTextBox}"  Text="{Binding Path= MessageToSend, Mode= TwoWay, UpdateSourceTrigger= PropertyChanged}"></telerik:TxtDataProvider>
        </Grid>

    Here Binding works perfect. Now, I would like the user to enter 120 characters only in above RadRichTextBox in a manner  that whenever user enters 121st character the foregoround color of this character and exceeding characters changes to Red while typing itself. The first 120 characters will have default  foreground color.
    Please let me know how to implement this functionality with this RadRichTextBox in MVVM asap.

    Thanks
  2. Petya
    Admin
    Petya avatar
    975 posts

    Posted 11 Nov 2014 Link to this post

    Hi Pratham,

    I'm afraid I am unable to recommend a way to achieve the desired behavior in an MVVM scenario. While it is possible to determine which are the last N characters in the control and execute actions over them, the fact that the control is bound with a plain-text provider will strip all formatting you apply.

    Let me know if you have other questions.

    Regards,
    Petya
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top