WPF ToolTip containing buttons can not recieve Mouse events, alternative?

╄→尐↘猪︶ㄣ 提交于 2019-12-08 09:01:26

问题


I want a formatbar like in Office 2010 with WPF:

  • Select Text and then click buttons on appearing tooltip to execute a command

How can I make that work?


回答1:


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>


来源:https://stackoverflow.com/questions/3444273/wpf-tooltip-containing-buttons-can-not-recieve-mouse-events-alternative

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!