RadMaskCurrencyInput don't NotifyOnValidationError

9 posts, 0 answers
  1. Umbala
    Umbala avatar
    28 posts
    Member since:
    Mar 2010

    Posted 07 Apr 2011 Link to this post

    Hi telerik team!
    I meet with problem when use RadMaskCurrencyInput
    XAML:

    <Grid x:Name="LayoutRoot" Background="White" BindingValidationError="LayoutRoot_BindingValidationError" >
      <sdk:RadMaskedCurrencyInput x:Name="maskInput" Mask="c3.0" Value="{Binding Cost,Mode=TwoWay,ValidatesOnExceptions=True,NotifyOnValidationError=True}" />                        
    </Grid>

    When RadMaskedCurrencyInput binding error Debugger don't run into LayoutRoot_BindingValidationError which handle BindingValidationError event of LayoutRoot. Please give me a solution to resolve this problem.
    Thanks !
  2. Alex Fidanov
    Admin
    Alex Fidanov avatar
    636 posts

    Posted 07 Apr 2011 Link to this post

    Hello Umbala,

    I tested this with the release version of Q1 and this worked correctly. The parent Grid panel is handling the BindingValidationError event as expected. Can you confirm that your binding is not failing and that you are correctly raising the validation exception.

    Best wishes,
    Alex Fidanov
    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. DevCraft banner
  4. Umbala
    Umbala avatar
    28 posts
    Member since:
    Mar 2010

    Posted 07 Apr 2011 Link to this post

    Please try to run my code
    XAML:
    <Grid x:Name="LayoutRoot" Background="White" BindingValidationError="LayoutRoot_BindingValidationError" >
           <Grid.RowDefinitions>
               <RowDefinition Height="Auto"/>
               <RowDefinition Height="Auto"/>
           </Grid.RowDefinitions>
           <Grid.ColumnDefinitions>
               <ColumnDefinition Width="Auto"/>
               <ColumnDefinition Width="Auto"/>
               <ColumnDefinition Width="Auto"/>
           </Grid.ColumnDefinitions>
           <TextBlock Text="{Binding OrderName}" Grid.Column="0" Margin="8"/>
           <sdk:RadMaskedCurrencyInput x:Name="maskInput"  Mask="c3.0" Grid.Column="1" Value="{Binding Cost,Mode=TwoWay,ValidatesOnExceptions=True,NotifyOnValidationError=True}" Margin="8"/>                        
       </Grid>
    Code:
    Imports System.ComponentModel.DataAnnotations
      
    Partial Public Class MainPage
        Inherits UserControl 
      
        Public Sub New()
            InitializeComponent()
            Me.DataContext = New Order("Order1", Nothing)
        End Sub
      
        Private Sub LayoutRoot_BindingValidationError(sender As System.Object, e As System.Windows.Controls.ValidationErrorEventArgs)
            MessageBox.Show(e.Error.ToString)        
        End Sub
      
    End Class
      
    Public Class Order
        Public Sub New(ByVal strOrderName As String, dCost As Double)
            Me.OrderName = strOrderName
            Me.Cost = dCost
        End Sub
      
        Public Property OrderName As String
      
        <Required(ErrorMessage:="Required")> _
        Public Property Cost() As Double     
    End Class

    I want to when RadMaskedCurrencyInput show error message "Required", LayoutRoot_BindingValidationError event is handle
    Thanks!
  5. Umbala
    Umbala avatar
    28 posts
    Member since:
    Mar 2010

    Posted 08 Apr 2011 Link to this post

    Please help me!
  6. Alex Fidanov
    Admin
    Alex Fidanov avatar
    636 posts

    Posted 08 Apr 2011 Link to this post

    Hello Umbala,

    I am not sure if the data annotation attributes will raise the BindingValidationError event. What you can try is to throw a ValidationException in the setter of the bound property.

    private double cost;
    public double Cost
    {
        get { return cost; }
        set
        {
            if (value > 50)
            {
                throw new ValidationException("Cost cannot be greater than 50");
            }
            cost = value;
            this.OnPropertyChanged("Cost");
        }
    }


    Regards,
    Alex Fidanov
    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
  7. Umbala
    Umbala avatar
    28 posts
    Member since:
    Mar 2010

    Posted 08 Apr 2011 Link to this post

    If using RadMaskTextbox instead of using RadMaskCurrencyInput every thing work fine.
    My project is using data annotation attributes to validate data and I can't change this mechanism. Please show me how to handles BindingValidationError event  if using data annotation attributes  to validate data because all of entity in my project inherit from System.ServiceModel.DomainServices.Client.Entity   and use ValidateProperty() of System.ServiceModel.DomainServices.Client.Entity  method to validate data

    Public Class Order
        Inherits System.ServiceModel.DomainServices.Client.Entity
       
        Public Sub New(dCost As Double)        
            Me.Cost = dCost
        End Sub
     
        Private m_Cost As Double
        <Range(1, 5, ErrorMessage:="invalid")> _
        Public Property Cost() As Double
            Get
                Return m_Cost
            End Get
            Set(ByVal Value As Double)
                If Value <> Nothing Then
                    Me.ValidateProperty("Cost", Value)
                    m_Cost = Value
                End If
            End Set
        End Property
  8. Umbala
    Umbala avatar
    28 posts
    Member since:
    Mar 2010

    Posted 10 Apr 2011 Link to this post

    Please help me!
  9. Umbala
    Umbala avatar
    28 posts
    Member since:
    Mar 2010

    Posted 13 Apr 2011 Link to this post

    ???
  10. Alex Fidanov
    Admin
    Alex Fidanov avatar
    636 posts

    Posted 13 Apr 2011 Link to this post

    Hello Umbala,

    We have acknowledged this as an issue in the masked input controls. It is logged in our PITS and you can follow its progress from here.

    Greetings,
    Alex Fidanov
    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
Back to Top
DevCraft banner