How to define a default tooltip style for all Controls

Posted by skjagini on Stack Overflow See other posts from Stack Overflow or by skjagini
Published on 2010-12-01T04:43:30Z Indexed on 2010/12/31 15:54 UTC
Read the original article Hit count: 267

Filed under:
|
|

I would like to define a style with a template when there are validation errors and would display the first error message as a tooltip.

It works fine when targeting specific control like DatePicker in the following xaml.

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

I cannot get it to work for Control though, i.e. the following doesn't give any tooltip

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

Any idea?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about xaml