4

I'm using SharpVectors library in my WPF app to display SVG icons instead of the traditional PNGs. I'm using the following basic pattern throughout my XAML:

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

The problem is that the tooltip I set on my button doesn't show through the SvgViewbox. It only shows when mouse is hovering over the button's 2px margin that isn't covered by the SvgViewbox element.

Contrast with this, where tooltip shows over the entire button surface, as expected:

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

I tried setting the tooltip on the SvgViewbox directly, but it makes no difference. What else can I do to make this work?

PaulusHub
  • 385
  • 1
  • 4
  • 17
aoven
  • 2,248
  • 2
  • 25
  • 36
  • `WPF` can display Vector Graphics out of the box! `Path` or `Rectangle` or `Ellipse` are just all vectors. If you want to use vector graphics they need to be in the right format, I use `Inkscape` to export vector images as xaml files. Then use `ViewBox`. – XAMlMAX Oct 25 '18 at 07:30
  • I will consider this method, thanks! – aoven Oct 25 '18 at 10:43

1 Answers1

4

I'm not familiar with SvgViewbox, but try to set property IsHitTestVisible to False for the SvgViewbox:

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