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. 

             x:Name="Pv" Grid.Row="0" Grid.Column="1" 
             SelectionOnFocus="SelectAll" HorizontalAlignment="Center" 
             ErrorMessage="{Binding PvErrorMessage}"
             EmptyContent="Enter a Principal">
                 <Binding Path="Pv" 
                          NotifyOnValidationError="True" ValidatesOnExceptions="True">
                             ProductId="{Framework:DataResourceBinding DataResource={StaticResource ProductId}}" 
                             Type="{Framework:DataResourceBinding DataResource={StaticResource Principal}}"
                             BringForward="{Framework:DataResourceBinding DataResource={StaticResource BringForward}}">

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

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


        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
    Peshito avatar
    522 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.

    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
Back to Top