How to update a Bool upon Error Validation

2 posts, 0 answers
  1. Minh
    Minh avatar
    43 posts
    Member since:
    May 2014

    Posted 29 Oct 2015 Link to this post

    at the moment I have a text box with some validation code. In the program they can set the range acceptable by the input box. I'm wondering how would I disable a buttom if the validation failed for the input box. At the moment if my validation fails, a ErrorMessage Prompt appears saying it's out of the acceptable range. 

         <telerik:RadMaskedCurrencyInput 
             x:Name="Pv" Grid.Row="0" Grid.Column="1" 
             IsClearButtonVisible="True" 
             SelectionOnFocus="SelectAll" HorizontalAlignment="Center" 
             Width="108"
             ErrorMessage="{Binding PvErrorMessage}"
             AutoFillNumberGroupSeparators="False"
             MaskedInput:MaskedInputExtensions.Minimum="0"         
             EmptyContent="Enter a Principal">
             <telerik:RadMaskedCurrencyInput.Value>
                 <Binding Path="Pv" 
                          UpdateSourceTrigger="PropertyChanged"                                         
                          NotifyOnValidationError="True" ValidatesOnExceptions="True">
                     <Binding.ValidationRules>
                         <Framework:IntValidationRule   
                             ValidatesOnTargetUpdated="True"   
                             ProductId="{Framework:DataResourceBinding DataResource={StaticResource ProductId}}" 
                             Type="{Framework:DataResourceBinding DataResource={StaticResource Principal}}"
                             BringForward="{Framework:DataResourceBinding DataResource={StaticResource BringForward}}">
                         </Framework:IntValidationRule>
                     </Binding.ValidationRules>
                 </Binding>
             </telerik:RadMaskedCurrencyInput.Value>
         </telerik:RadMaskedCurrencyInput>

    If the masked input box has an error, I would like to disable my Button

         <Button Content="Calculate"
                 IsEnabled="{Binding CalculatorEnabled}">

    Example:

        Range $1-$10,000

        I input $50,000
        Calculator Enabled should be 'False'

    How do I update CalculatorEnabled if there's been a validation fail or pass?  

  2. Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 03 Nov 2015 Link to this post

    Hello Minh,

    You could bind your button's IsEnabled property to a property of your ViewModel where that property should be updated whenever the validation fails.

    Hope this helps.

    Regards,
    Peshito
    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
Back to Top