防止工具提示用于子控件 [英] Prevent ToolTip for child controls

查看:60
本文介绍了防止工具提示用于子控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我在WPF窗口中有以下代码:

Lets say I have following code in a WPF Window:

<ct:CustomClass.CustomStack>
                        <StackPanel Name="TB1">
                            <Button ToolTip="Test Tip" BorderThickness="1" BorderBrush="Black" Name="btnModifier" Content="Click here"></Button>
                        </StackPanel>
                    </ct:CustomClass.CustomStack>



在其中有一个自定义堆栈面板属性的地方,我要在其中添加一个带有孩子的堆栈面板.
现在,如我们所见,按钮在此处具有工具提示,当鼠标悬停在其上时将显示该工具提示.
我无法控制该按钮,因为它位于另一个窗口(某些使用我的自定义类的主机应用程序)中.

主要问题是我希望堆栈面板中子控件的工具提示永远不要在鼠标悬停时的运行时出现.如何在我的自定义课程中实现这一目标?

注意:我对主机应用程序窗口中的代码没有任何控制.xaml



Where I have a custom stack panel property where I am adding a stackpanel with children in it.
Now as we see button has a tooltip here which will be displayed when mouse will hover on it.
I have no control over the button as it lies inside another window (some host application using my custom class).

Main question is I want that the tooltip for child control in stackpanel should never appear at runtime during mouse hover. How to achieve this in my custom class?

Note: I don''t have any control over code in Host application window.xaml

推荐答案

我将把工具提示绑定到一个可观察到的字符串集合,并在添加元素时将它们绑定到元素.使它更简单.

但是,您只能在堆栈面板中的元素上设置样式,请参见此处:
http://stackoverflow.com/questions/1366598/apply-style-to-all-treeviewitem [^ ]
http://stackoverflow.com/questions/1465806/applying-wpf-styles-to-子项 [ ^ ]
I would insted binded the Tooltips to an Observable collection of string, and binded these to the elements as they get added. MAkes it simpler.

You can however set the style on only the elements within the stackpanel see here:
http://stackoverflow.com/questions/1366598/apply-style-to-all-treeviewitem[^]
http://stackoverflow.com/questions/1465806/applying-wpf-styles-to-child-items[^]


这篇关于防止工具提示用于子控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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