Tooltip Not Showing Up When No Validation Error WPF

怎甘沉沦 提交于 2019-12-05 10:01:59

In your style triggers you set the tooltip to the Validation error when you have an error. You can do the same when you don't have an error by manipulating the Value property of the Trigger

<Style x:Key="StandardComboBoxStyle" TargetType="{x:Type ComboBox}">
    <Style.Triggers>
        <Trigger Property="Validation.HasError" Value="True">
            <Setter Property="ToolTip" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.Errors)[0].ErrorContent}"/>
        </Trigger>
        <Trigger Property="Validation.HasError" Value="False">
            <Setter Property="ToolTip" Value="My tooltip test." />
        </Trigger>
    </Style.Triggers>
</Style>

On another note I'd recommend changing Path=(Validation.Errors)[0].ErrorContent to Path=(Validation.Errors).CurrentItem.ErrorContent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!