包含按钮的 WPF ToolTip 无法接收鼠标事件,替代方法? [英] WPF ToolTip containing buttons can not recieve Mouse events, alternative?

查看:18
本文介绍了包含按钮的 WPF ToolTip 无法接收鼠标事件,替代方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个带有 WPF 的 Office 2010 中的格式栏:

I want a formatbar like in Office 2010 with WPF:

  • 选择文本,然后单击出现的工具提示上的按钮以执行命令

我怎样才能做到这一点?

How can I make that work?

推荐答案

ToolTip 窗口无法接受焦点,请使用 弹出 控件.它比工具提示更麻烦,因为许多有用的属性默认设置为 false,这是一个小例子:

The ToolTip window can't accept focus, use the Popup control instead. It's a bit more cumbersome, than a tooltip, because many useful properties are set to false by default, here is a tiny example:

<Popup x:Name="samplePopup" PopupAnimation="Fade" Placement="Mouse" AllowsTransparency="True" StaysOpen="False" >
      <Popup.Child>
         <StackPanel Margin="10" >
                <TextBlock Text="Some Text" HorizontalAlignment="Center" />

                <Button Content="Close" HorizontalAlignment="Center" />
         </StackPanel>
      </Popup.Child>
</Popup>

这篇关于包含按钮的 WPF ToolTip 无法接收鼠标事件,替代方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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