views:

986

answers:

1

Experimenting with WPF validating input, I tried to use ToolTip for displaying results of TextBox input validation, like this:

<Style.Triggers>
 <Trigger Property="Validation.HasError" Value="true">
    <Setter
        Property="ToolTip" 
        Value="{Binding RelativeSource={RelativeSource Self},
        Path=(Validation.Errors)[0].ErrorContent}"/>
    </Trigger>
</Style.Triggers>

It seemed for me very inconvenient, that ToolTip is shown not in the process of typing text in the Textbox, at the moment when validating error occurs, but only after mousepointer put intentionally over the TextBox.

This seems violating user expectation regarding usability of UI, so I prefered putting the Validation Error results in a separate TextBlock, automatically and instantly appearing at the moment, when input validation error occurs.

But maybe I'm wrong and don't use ToolTip properly? Maybe there are settings of ToolTip properties making ToolTip able appearing without intentional mousehover over TextBox?

Edited (added):

Using ToolTip for displaying results of TextBox input validation I have found in Microsoft MSDN documentation:

http://msdn.microsoft.com/en-us/library/ms752347.aspx#data_validation

Do you use ToolTips for showing validation errors? If so, how you get along with the fact that user can never see it (if he/she doesn't guess to hover a mouse over a textbox)?

+1  A: 

I believe you are using ToolTip the wrong way, the ToolTip property is meant to provide small contextual help to the user about a certain control when they hover their mouse over it, that's why it only appears on mouse-overs.

For example, if you have a text box for a user to enter their phone number, you may want to provide a tooltip saying "Please type your phone number here."

For form validation, your TextBlock idea sounds much better. Plus you have great control over the display since its a full fledge control.

Patrick Pohler
Thanks, Patrick! The fact is, the usage of ToolTip for displaying results of TextBox input validation can be found in Microsoft MSDN documentation. I have added a link to my edited question.
rem
Huh, I have never seen ToolTip used like that. Thanks for the link rem!
Patrick Pohler