Validating / Styling

2 posts, 0 answers
  1. Martin Egger
    Martin Egger avatar
    6 posts
    Member since:
    Mar 2010

    Posted 30 Apr 2010 Link to this post


    I have a small problem. When I validate a TextBoxes Value and than giving the User a visual feedback everything works prefectly fine.

    When I do this with a RadComboBox, the only thing that works is the validation part. But I don't get any visual feedback. Here is the XAML part in my App.xaml

    <Application x:Class="CDM.App" 
        <Storyboard x:Key="FlashError"
                <ObjectAnimationUsingKeyFrames BeginTime="00:00:00"  
                    <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Visible}"/> 
                    <DiscreteObjectKeyFrame KeyTime="00:00:05" Value="{x:Static Visibility.Hidden}"/> 
        <Style x:Key="myErrorTemplate" TargetType="Control"
            <Setter Property="Validation.ErrorTemplate"
                        <StackPanel Orientation="Vertical"
                            <Border BorderBrush="Red" BorderThickness="1"
                                <AdornedElementPlaceholder Name="mycontrol"
                                    <Label Foreground="White" Background="Red"  
                                               Content="{Binding ElementName=mycontrol,  
                                                <EventTrigger RoutedEvent="FrameworkElement.Loaded"
                                                    <BeginStoryboard Storyboard="{StaticResource FlashError}" /> 
                            <!--<Label Foreground="White" Background="Red"  
                                               Content="{Binding ElementName=mycontrol,  
                <Trigger Property="Validation.HasError" Value="true"
                    <Setter Property="ToolTip"  
                                        RelativeSource={x:Static RelativeSource.Self}, 
                                        Path=(Validation.Errors)[0].ErrorContent}" /> 
          <Style TargetType="TextBox" BasedOn="{StaticResource myErrorTemplate}" /> 
        <Style TargetType="CheckBox" BasedOn="{StaticResource myErrorTemplate}" /> 
            <Style TargetType="telerik:RadComboBox" BasedOn="{StaticResource myErrorTemplate}" /> 

    And here the the C# Part for Validation. Allthough I am convincied that the validation works. Tested it several times.

        public Platten() 
                this.preisReference.AssociationChanged += new CollectionChangeEventHandler(preisReference_AssociationChanged); 
                this.AddError("preis""Preiscode fehlt!"); 
            void preisReference_AssociationChanged(object sender, CollectionChangeEventArgs e) 
                if (e.Action == CollectionChangeAction.Remove) 
                    if (e.Action == CollectionChangeAction.Add) 
            #region IDataErrorInfo Members 
            private Dictionary<stringstring> m_validationErrors = new Dictionary<stringstring>(); 
            private void AddError(string columnName, string msg) 
                if (!m_validationErrors.ContainsKey(columnName)) 
                    m_validationErrors.Add(columnName, msg); 
            private void RemoveError(string columnName) 
                if (m_validationErrors.ContainsKey(columnName)) 
            public bool HasErrors 
                get { return m_validationErrors.Count > 0; } 
            public string Error 
                    if (m_validationErrors.Count > 0) 
                        return "Customer data is invalid"
                        return null
            public string this[string columnName] 
                    if (m_validationErrors.ContainsKey(columnName)) 
                        return m_validationErrors[columnName]; 
                    else return null

    Thanks for your help.

  2. Hristo
    Hristo avatar
    832 posts

    Posted 06 May 2010 Link to this post

    Hello Martin Egger,

    We are unable to run your project because there are missing parts.
    Could you send us sample project (you have to open a support ticket in order to attach files) so that we can be sure that we are working on the same issue?

    Kind regards,
    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.
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top