0

I have a WPF Label which lays on top of Rectangles. These Rectangles have individual Tooltips. I want to show the Tooltip of the underlying Rectangle and ignore the Tooltip of the Label, how can I do this in wpf/c#.

  • 1
    Please share the code and other details to under your question. Also check https://stackoverflow.com/questions/46004591/wpf-c-sharp-statusbar-label-content-from-current-controls-tooltip – Praveen Poonia Sep 21 '18 at 06:16
  • 1
    Please read about [how to ask good questions](https://stackoverflow.com/help/how-to-ask) and learn about [how to create a Minimal, Complete and Verifiable Example](https://stackoverflow.com/help/mcve). – Gaurang Dave Sep 21 '18 at 06:24

3 Answers3

1

You can set the IsHitTestVisible property of the labels to False so that the rectangles will receive the input from the mouse instead of the label.

Julien Poulin
  • 12,737
  • 10
  • 51
  • 76
0

Without the code it's har to tell how you actually want it to do

I would simply use the same method for the Tooltips

<Label Name="L1" ToolTipOpening="ToolTipMethod">
<Label Name="L2" ToolTipOpening="ToolTipMethod">

private void ToolTipMethod(object sender, ToolTipEventArgs e)
{
    //your code
}
Shmosi
  • 322
  • 2
  • 17
0

I suppose you might want something like this:

enter image description here

This is just in pure xaml:

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*" />
        <ColumnDefinition Width="*" />
        <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>

    <Rectangle Grid.Row="0"
               ToolTip="Rectangle 1"
               Fill="Red" />

    <Label Grid.Column="0"
           Content="Label"
           HorizontalAlignment="Left"
           VerticalAlignment="Top"
           Width="50"
           Height="30"
           Background="LightBlue"/>

    <Rectangle Grid.Column="1"
               ToolTip="Rectangle 2"
               Fill="IndianRed" />

    <Label Grid.Column="1"
           Content="Label"
           HorizontalAlignment="Left"
           VerticalAlignment="Top"
           Width="50"
           Height="30"
           Background="LightBlue"/>

    <Rectangle Grid.Column="2"
               ToolTip="Rectangle 3"
               Fill="Red" />

    <Label Grid.Column="2"
           Content="Label"
           HorizontalAlignment="Left"
           VerticalAlignment="Top"
           Width="50"
           Height="30"
           Background="LightBlue"/>
</Grid>

Of course you can work out better ways on how to position the labels and defining their size to get what you want, this is merely an example.

Faenrig
  • 197
  • 1
  • 9