根据验证错误启用按钮

时间:2015-10-29 14:05:54

标签: c# wpf

目前我有一个带有一些验证码的文本框。在程序中,他们可以设置输入框可接受的范围。我想知道如果输入框的验证失败,我将如何禁用buttom。目前,如果我的验证失败,则会出现ErrorMessage Prompt,说明它超出了可接受的范围。

 <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>

如果屏蔽的输入框有错误,我想禁用我的按钮

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

示例:

Range $1-$10,000

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

如果验证失败或通过,如何更新CalculatorEnabled?

0 个答案:

没有答案