我怎么能显示工具提示不断,而控制的重点是? [英] How can I display a tooltip constantly while a control is focused?

查看:132
本文介绍了我怎么能显示工具提示不断,而控制的重点是?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么能显示工具提示不断,而控制的重点是?我试过这么多的东西,似乎没有任何工作。现在我有类似如下:

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 IsKeyboardFocused, 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>

看起来像它应该工作很简单,但事实并非如此。为什么不呢?我的工具提示的IsOpen属性绑定到文本框的IsKeyboardFocused属性。因此,它应该显示而提示的重点。为什么不呢?

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.

这篇关于我怎么能显示工具提示不断,而控制的重点是?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆