tags:

views:

1507

answers:

1

This a test message

private void btnClick_Click_1(object sender, RoutedEventArgs e)
{
    txtInput.Focus();
    ToolTipTest.IsVisible = true;
}

When the button is clicked the tooltip is shown on the button, I want to simulate putting mouse pointer on the textbox, the toolbox to be shown for the textbox

+3  A: 

First of all, you should be using the standard validation for something like what you are doing. From your comment above I can tell that's what you are doing and you should know that WPF has a really good builtin system for doing exactly what you want without doing it so imperatively (and very reusable).

Here's an example of a style you can apply to, say, all textboxes when the value the are bound to doesn't validate (using IDataErrorInfo).

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

You might also consider a more standard UI that utilizes the adorner layer to put a validation failure indicator next to the control that failed validation. Here's a sample on that:

http://blogsprajeesh.blogspot.com/2009/03/handling-error-in-wpf-idataerrorinfo.html

Good luck.

Anderson Imes