Always show WPF TextBox Tooltip
Is it possible to display tooltip constantly, not depending on whether the control is focused ot not, but depending only on the value of the bind property.
<TextBox Name="projectTextBox"
ToolTipService.Placement="Bottom" ToolTipService.ShowDuration="12000"
MinWidth="150" Text="{Binding ProjectName}" IsEnabled="{Binding IsEnabled}">
<TextBox.ToolTip>
<ToolTip Placement="Bottom"
StaysOpen="True" Content="TEXT"
V开发者_StackOverflow社区isibility="{Binding IsNotFound, Converter={StaticResource booleanToVisibilityCollapsedConverter}}"
IsOpen="True">
</ToolTip>
</TextBox.ToolTip>
</TextBox>
you should use an adorner for the behavior you are looking for. you can use a datatrigger or what you want to show the adorner as long as you want. btw with an adorner you did not have the problems popups have, while moving the mainwindow.
Why not set the tooltip based on a trigger?
<TextBox Name="projectTextBox" ToolTipService.Placement="Bottom" ToolTipService.ShowDuration="12000" MinWidth="150" Text="{Binding ProjectName}" IsEnabled="{Binding IsEnabled}">
<TextBox.Style>
<Style TargetType="{x:Type TextBox}">
<Style.Triggers>
<DataTrigger Binding="{Binding IsNotFound}" Value="False">
<Setter Property="ToolTip">
<Setter.Value>
<ToolTip Placement="Bottom" StaysOpen="True" Content="TEXT" IsOpen="True" />
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>
Basically, you cannot force the tooltip to be shown constantly, because Windows is the one who decides when the tooltip hides (usually on MouseLeave or after some amount of time) to keep the look and feel of the applications consistent (The tooltip control is made to act this way).
If you want to display some helpful information to the user in a way that differs from the standard Windows tooltip way, you should consider using something else than a ToolTip, maybe a Popup or something similar with the FormNotification control from this article.
You can consider using Popup instead. Or if you are using material design for WPF, you can consider using PopupBox. I know I late for the party this time.
精彩评论