c# - SvgViewbox 在鼠标悬停时不显示工具提示

标签 c# wpf xaml svg

我在我的 WPF 应用程序中使用 SharpVectors 库来显示 SVG 图标而不是传统的 PNG。我在整个 XAML 中使用以下基本模式:

<Button ToolTip="My doodad">
    <svgc:SvgViewbox Height="16" Width="16" Margin="2" Source="pack://application:,,,/Resources/svg/mydoodad.svg" />
</Button>

问题是我在按钮上设置的工具提示没有通过 SvgViewbox 显示。它仅在鼠标悬停在未被 SvgViewbox 元素覆盖的按钮的 2px 边距上时显示。

与此形成对比,工具提示显示在整个按钮表面上,如预期的那样:

<Button ToolTip="My doodad">
    <Viewbox Width="16" Height="16" Margin="2">
        <Image Source="pack://application:,,,/Resources/png/mydoodad.png"></Image>
    </Viewbox>
</Button>

我尝试直接在 SvgViewbox 上设置工具提示,但没有任何区别。我还能做些什么来完成这项工作?

最佳答案

我不熟悉 SvgViewbox,但尝试将属性 IsHitTestVisible 设置为 False 对于 SvgViewbox:

<Button ToolTip="My doodad">
    <svgc:SvgViewbox IsHitTestVisible="False" Height="16" Width="16" Margin="2" Source="pack://application:,,,/Resources/svg/mydoodad.svg" />
</Button>

关于c# - SvgViewbox 在鼠标悬停时不显示工具提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52982771/

相关文章:

c# - 如何知道何时按下 ctrl+space?

c# - 如何刷新 Canvas

c# - 绑定(bind) DataTemplate 中的 RotateTransform Angle 未生效

c# - 如何创建一个可以在 C# 中的任何异常上执行的方法?

c# - 我可以在 LINQ 中声明/使用一些变量吗?或者我可以更清楚地编写以下 LINQ 吗?

wpf - 如何使用 RowDefinition Height * 获取网格的实际网格行高

wpf - 如何在 XAML 中获取容器(如 dll)中的特定图标?

c# - 使用 Targus Laptop Dock 的 Visual Studio Update 3 中的 System.Runtime.Remoting.RemotingException

c# - 如何在单个 mvc3 View 中添加两个表?

c# - 如何阅读在 asp.net 核心 web api 中发布的 FormUrlEncodedContent?