MahApps.Metro中Tooltip变黑框问题的解决

最近自己在用MahApps.Metro时发现写的程序中的tooltip不知怎么总是显示为一个黑框,无法调节背景。搜索无果,经过一翻折腾后查看了WPF原版ToolTip的模板,经过排除发现在Window中加入如下资源便可避免这个问题:

  <Window.Resources>
          <!--if do not have this style, the problem will appear.-->
          <Style TargetType="ToolTip">
          </ Style>
  </ Window.Resources>

我把这个bug到github向作者反映了一下,他说可能是由一个已知的MahApps.Metro样式问题造成的,以下是回复:

So a few things I have discovered from a quick test.

The following will work:

<Control.Tooltip>
    My tooltip text
</Control.Tooltip>

The following will not work:

<Control.Tooltip>
       <ToolTip>
           <TextBlock TextWrapping="Wrap">
               My tooltip test.
           </TextBlock>
       </ToolTip>
</Control.Tooltip>

EDIT:
@tp7309 The problem may be because of the known 'issue' MA.M has with styles in App.xaml. Move your resources into your window's resources and delete them from App.xaml.


他建议将Tooltip内容修改,

  Amrykid  commented 16 hours ago

You also have to remove the TextBlock from your tooltip. It should look like this:

<Control.Tooltip>
    My tooltip text
</Control.Tooltip>

也建议资源从App.xaml移到Window中,将MA.M升级到最新alpha版,不过试验没起什么效果.


你可能感兴趣的:(tooltip,WPF)