I have a control grid, where each editable control (checkbox, combo box, etc.) has an associated label. I want to share a hint between a tag and its control.
Now this is what I accomplished with BindableToolTips : I just define ToolTip in my XAML resources and then set the same tooltip object separately on the label and control.
code:
<TextBlock Grid.Row="0" Grid.Column="0" ToolTipService.PlacementTarget="{Binding ElementName=ExampleControl}" Utilities:ToolTipServiceExtended.BindableToolTip="{StaticResource ExampleControlTT}" Text="Example label:" /> <CheckBox Grid.Row="0" Grid.Column="1" x:Name="ExampleControl" Utilities:ToolTipServiceExtended.BindableToolTip="{StaticResource ExampleControlTT}" Content="Example" />
Unfortunately, this does not make it smooth ... When the mouse moves from a label to a control or from a control to a label, the tooltip disappears and reopens, and a flicker appears. This happens even when there is no gap between the mark and the control, and it does not look very good. This, obviously, is because these are two separate clues.
I would like to somehow group a shortcut and its associated control and show a tooltip in this separate group; thus, it may appear fluid and not flicker when the mouse moves between them. Unfortunately, I'm struggling to do this. Here are some things I've tried ...
Empty text box using tooltip and ColumnSpan = 2.
Unfortunately, this prevents the control from getting mouse clicks, since the TextBlock hides it invisibly. I tried to set IsHitTestVisible to false, but then this prevents it from getting the mouse over events, which stops the tooltip. If I could just make it so that the mouse clicks through an empty TextBlock, but the TextBlock still hoveres over the events, then that would be great.
code:
<TextBlock Grid.Row="0" Grid.Column="0" Text="Example label:" /> <CheckBox Grid.Row="0" Grid.Column="1" x:Name="ExampleControl" Content="Example" /> <TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" ToolTipService.PlacementTarget="{Binding ElementName=ExampleControl}" Utilities:ToolTipServiceExtended.BindableToolTip="{StaticResource ExampleControlTT}" />
A nested grid specifically for one label and one control.
This method works: a tooltip appears whenever the mouse is somewhere on the internal grid, and the mouse events are still successfully passed to the control. Unfortunately, this has three problems:
- This is very dirty since I will need a lot of nested grids for each combination of labels / controls.
- The widths of the Auto columns no longer take into account the widths of other controls in the external grid, because this, of course, is a separate grid.
- It appears that the tooltip placement settings, which are Placement = Right, and PlacementTarget, are a special control, are ignored. Instead, a tooltip appears below the internal grid.
If the last two problems can be fixed, this will be an acceptable solution.
code:
<Grid Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" ToolTipService.PlacementTarget="{Binding ElementName=ExampleControl}" Utilities:ToolTipServiceExtended.BindableToolTip="{StaticResource ExampleControlTT}"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <TextBlock Grid.Row="0" Grid.Column="0" Text="Example label:" /> <CheckBox Grid.Row="0" Grid.Column="1" x:Name="ExampleControl" Content="Example" /> </Grid>
Does anyone have any ideas for a good solution to this problem? I just want my tooltips to appear both above the label and with the corresponding control, as if they were one element, without flickering, when the mouse moves between them. It's all.