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

Trigger ToolTip on buttonclick

1 Answer 212 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 24 Sep 2014, 01:32 PM
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");
    }
}

1 Answer, 1 is accepted

Sort by
0
Pavel R. Pavlov
Telerik team
answered on 25 Sep 2014, 11:11 AM
Hello,

I can see the UpdateSourceTrigger property of the binding is set to PropertyChanged. This means that every time you type into the control, the validation logic will be triggered. In order to achieve your requirements you can use some of the other valid values.

Also, you can take a look at this post and evaluate the approach that is suggested there. It might be effective in your particular case.

Regards,
Pavel R. Pavlov
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
MaskedInput (Numeric, DateTime, Text, Currency)
Asked by
Minh
Top achievements
Rank 1
Answers by
Pavel R. Pavlov
Telerik team
Share this question
or