Reputation: 3
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#.
Upvotes: 0
Views: 207
Reputation: 13025
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.
Upvotes: 1
Reputation: 197
I suppose you might want something like this:
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.
Upvotes: 0
Reputation: 332
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
}
Upvotes: 0