0
我在StackOverflow上找到了各種答案,他們都沒有幫助我。 我想關閉文本框驗證IsEnabled="false"
我在這裏丟失了什麼?如何在TextBox屬性IsEnabled爲false時禁用驗證?
<TextBox x:Name="idTxtBox">
<!--This is where I tried to disable validation-->
<TextBox.Style>
<Style TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}">
<Style.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Validation.ErrorTemplate" Value="{x:Null}"/>
</Trigger>
</Style.Triggers>
</Style>
</TextBox.Style>
<!--I want to disable these validation rules-->
<TextBox.Text>
<Binding Path="ID" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<val:RequiredFieldValidation ValidationStep="RawProposedValue"/>
<val:IsNumberValidation Min="1" Max="250" ValidationStep="ConvertedProposedValue"/>
<val:UniqueIDTag ValidationStep="RawProposedValue"/>
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
<Validation.ErrorTemplate>
<!--........-->
</Validation.ErrorTemplate>
</TextBox>