WPF TextBox Validating results ToolTip
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:
https://learn.microsoft.com/en-us/dotnet/desktop/wpf/data/?view=netdesktop-5.0&redirectedfrom=MSDN#data-validatio开发者_开发技巧n
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)?
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.
精彩评论