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

RichTextBox and IDataErrorInfo

3 Answers 71 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 10 Jun 2011, 10:48 AM
I am using IDataError info in my ViewModel with a property databound to a RadRichTextBox, however the RadRichTextBox does not show in the UI that it is in error. Does the RadRichTextBox not support IDataErrorInfo??

3 Answers, 1 is accepted

Sort by
0
Andrew
Telerik team
answered on 16 Jun 2011, 02:09 PM
Hi David,

We could not reproduce your issue. We use a RadRichTextBox bound to a property in the ViewModel and everything seems to work fine.
We attached a demo project illustrating our approach.
If you can't make it work please send us a demo with your problem. If you meet other difficulties contacts us again.

Best wishes,
Andrew
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
David
Top achievements
Rank 1
answered on 17 Jun 2011, 12:47 PM
Thanks for the response.

I amended your version of your solution to demonstrate the issue I am having.

You will see that when the page is loaded the regular textbox shows it is in error yet the radrichtextbox does not, even though IDataErrorInfo is returning an error message to the control.

Thanks

ViewModel

using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;
  
namespace SilverlightApplication37
{
    public class ViewModel : IDataErrorInfo, INotifyPropertyChanged
    {
        public ViewModel()
        {
            this.text = string.Empty;
        }
  
        private string text;
        public string Text
        {
            get
            {
                return this.text;
            }
            set
            {
                this.text = value;
                this.OnPropertyChanged(this, new PropertyChangedEventArgs("Text"));
            }
        }
  
        public string Error
        {
            get { return null; }
        }
  
        public string this[string propertyName]
        {
            get
            {
                switch (propertyName)
                {
                    case "Text":
                        if (string.IsNullOrEmpty(Text)) return "Error";
                        break;
                }
                return null;
            }
        }
  
        public event PropertyChangedEventHandler PropertyChanged;
        private void OnPropertyChanged(object sender, PropertyChangedEventArgs args)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(sender, args);
            }
        }
    }
}

View

<UserControl x:Class="SilverlightApplication37.MainPage"
    xmlns:txt="clr-namespace:Telerik.Windows.Documents.FormatProviders.Txt;assembly=Telerik.Windows.Documents"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
  
    <Grid x:Name="LayoutRoot" Background="White">
        <txt:TxtDataProvider Text="{Binding Text, ValidatesOnDataErrors=True, NotifyOnValidationError=True, Mode=TwoWay}" RichTextBox="{Binding ElementName=radRichTextBox}" />
        <telerik:RadRichTextBox x:Name="radRichTextBox" Height="139" IsSpellCheckingEnabled="False" Margin="12,12,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="307">
        </telerik:RadRichTextBox>
        <TextBox Text="{Binding Text, ValidatesOnDataErrors=True, NotifyOnValidationError=True, Mode=TwoWay}" Height="23" HorizontalAlignment="Left" Margin="12,172,0,0" Name="textBox1" VerticalAlignment="Top" Width="307" />
    </Grid>
</UserControl>
0
Andrew
Telerik team
answered on 20 Jun 2011, 05:12 PM
Hello David,

Thank you for the report of this bug. Indeed there is a problem in the initial load of our control when using IDataErrorInfo.
We fixed it and you can see the change in our upcoming release in mid July.
We updated your Telerik points accordingly, in appreciation for your help.

If you have other concerns or suggestions, do not hesitate to get back to us.

Regards,
Andrew
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
RichTextBox
Asked by
David
Top achievements
Rank 1
Answers by
Andrew
Telerik team
David
Top achievements
Rank 1
Share this question
or