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

How to update a Bool upon Error Validation

1 Answer 95 Views
MaskedInput (Numeric, DateTime, Text, Currency)
This is a migrated thread and some comments may be shown as answers.
Minh
Top achievements
Rank 1
Minh asked on 29 Oct 2015, 03:15 PM

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?  

1 Answer, 1 is accepted

Sort by
0
Peshito
Telerik team
answered on 03 Nov 2015, 03:15 PM
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
Tags
MaskedInput (Numeric, DateTime, Text, Currency)
Asked by
Minh
Top achievements
Rank 1
Answers by
Peshito
Telerik team
Share this question
or