I'm trying to have Validation errors for my RadMaskedTextBox, Currently I was able to do that but it's dynamic and I want to change that.If I set the range only < 250, and I put 500 inside the textbox it'll trigger and the Validation Error will appear.What I want to happen is the Validation Error only happen when my button is pressed. May I ask how do I convert to do that?
Xaml
<ControlTemplate x:Key="validationTemplate">
<DockPanel>
<AdornedElementPlaceholder />
<TextBlock FontSize="20" Foreground="Red">Error!</TextBlock>
</DockPanel>
</ControlTemplate>
<controls:RadMaskedCurrencyInput
x:Name="radMaskedCurrencyInput"
InputBehavior="Insert"
Validation.ErrorTemplate="{StaticResource validationTemplate }"
Value="{Binding Path=DecimalValue,
ValidatesOnDataErrors=True,
ValidatesOnExceptions=True,
NotifyOnValidationError=false,
UpdateSourceTrigger=PropertyChanged}" />
<Button Content="Execute" cal:Message.Attach="[Click] = [ExecuteMessage]"/>ViewModel:private decimal decimalValue;
public decimal DecimalValue
{
get { return decimalValue; }
set
{
if (value > 250)
{
throw new ValidationException("Value cannot be greater than 250.");
}
else
decimalValue = value;
this.OnPropertyChanged("DecimalValue");
}
}
Xaml
<ControlTemplate x:Key="validationTemplate">
<DockPanel>
<AdornedElementPlaceholder />
<TextBlock FontSize="20" Foreground="Red">Error!</TextBlock>
</DockPanel>
</ControlTemplate>
<controls:RadMaskedCurrencyInput
x:Name="radMaskedCurrencyInput"
InputBehavior="Insert"
Validation.ErrorTemplate="{StaticResource validationTemplate }"
Value="{Binding Path=DecimalValue,
ValidatesOnDataErrors=True,
ValidatesOnExceptions=True,
NotifyOnValidationError=false,
UpdateSourceTrigger=PropertyChanged}" />
<Button Content="Execute" cal:Message.Attach="[Click] = [ExecuteMessage]"/>ViewModel:private decimal decimalValue;
public decimal DecimalValue
{
get { return decimalValue; }
set
{
if (value > 250)
{
throw new ValidationException("Value cannot be greater than 250.");
}
else
decimalValue = value;
this.OnPropertyChanged("DecimalValue");
}
}