How can I display a tooltip constantly while a control is focused?
How can I display a tooltip constantly while a control is focused? I've tried so many things and nothing seems to work. Right now I have something like the following:
<TextBox x:Name="textBox" Width="200">
<TextBox.ToolTip>
<ToolTip StaysOpen="{Binding I开发者_StackOverflowsKeyboardFocused, ElementName=textBox}" IsOpen="{Binding IsKeyboardFocused, ElementName=textBox}">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</ToolTip>
</TextBox.ToolTip>
</TextBox>
It seems like it should work very simply, but it doesn't. Why not? I'm binding the tooltip's IsOpen property to the textbox's IsKeyboardFocused property. Therefore, it should display while the tooltip is focused. Why doesn't it?
You can use a Popup
instead of a ToolTip
like this:
<Grid>
<StackPanel>
<TextBox x:Name="textBox1" Width="200" Height="20"/>
<TextBox x:Name="textBox2" Width="200" Height="20"/>
</StackPanel>
<Popup PlacementTarget="{Binding ElementName=textBox1}" IsOpen="{Binding IsKeyboardFocused, ElementName=textBox1, Mode=OneWay}">
<TextBlock Background="White">
<TextBlock.Text>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</TextBlock.Text>
</TextBlock>
</Popup>
</Grid>
and then style it to look like a tool tip.
精彩评论