Trigger ToolTip on buttonclick

2 posts, 0 answers
  1. Minh
    Minh avatar
    43 posts
    Member since:
    May 2014

    Posted 24 Sep 2014 Link to this post

    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");
        }
    }
  2. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 25 Sep 2014 Link to this post

    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.
     
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top