C # WPF Tooltips not showing in child grid

For some reason, tooltips do not appear in my child grid.

<Grid DockPanel.Dock="Top" Width="300px" Height="250px" ToolTipService.ToolTip="MainGrid Tooltip"> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="1.25*" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <Grid Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" ToolTip="mygrid tooltip 2"> <StackPanel Orientation="Horizontal"> <Image Width="15" Source="<<INSERT IMAGE FILE LOCATION HERE>>" ToolTipService.ToolTip="Child Grid Tooltip 1"/> <TextBlock Width="80" Text="Random Text 2" ToolTipService.ToolTip="Child Grid Tooltip 2"/> <TextBlock Width="80" Text="Random Text 3" ToolTipService.ToolTip="Child Grid Tooltip 3"/> </StackPanel> </Grid> 

I continue to display the "mygrid tooltip 2 tooltip", although I have redefined the tooltip for it - it will not be displayed.

I have reduced the complexity of having control patterns in resource dictionaries until I stay with this higher and still nothing.

any ideas would be greatly appreciated, as well as possibly links where I can read about it. my book WPF and msdn currently do not produce anything substantial.

thanks,

+4
source share
2 answers

@Isak, thanks, your Background="Transparent" helped in my final decision.

I eventually threw away the Grid with certain rows / columns and resorted to the Grid with nested StackPanels.

Grid.Rows used to be filled with ContentControls, I replaced it with local Stackpanels containing the information I needed to display, and which seemed to solve it, but only after I added the "Transparent" tag on the stack, as well as

 IsHitTestVisible="False" 

on the image in the parent grid, which serves as the background image.

Here is an example of my current solution, the second part, which replaces the code seen in my original post.

First, the main format of the source file before moving on to the code in question is as follows:

 <ResourceDictionary xmlns="... <DataTemplate DataType="... <Grid Style="... <Grid Grid.Row="1"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Grid Name="LeftColumn" Grid.Column="0"> <TextBlock Style="{StaticResource TextHeader}" Text="Review 10 Patients"/> <Image RenderOptions.BitmapScalingMode="NearestNeighbor" SnapsToDevicePixels="True" Stretch="None" DockPanel.Dock="Top" IsHitTestVisible="False" Source="((INSERT IMAGE HERE))" Margin="0,-2,0,10"/> 

And then my solution grid is as follows [replaces the initial zip code]:

  <StackPanel> <StackPanel Background="Transparent" Orientation="Horizontal"> <Image Style="{StaticResource InfoImage}" Margin="3"> <ToolTipService.ToolTip> <ToolTip Width="200" Style="{StaticResource ToolTip}" Content="ToolTip 1"/> </ToolTipService.ToolTip> </Image> <TextBlock Width="140" Style="{StaticResource Text_SelfTitle}" Text="Text Field 1"/> <TextBlock Width="145" Style="{StaticResource Text_SelfQuestions}" Text="Text Field 2"/> </StackPanel> <StackPanel Background="Transparent" Orientation="Horizontal"> ((... similar as above...)) </StackPanel> <StackPanel Background="Transparent" Orientation="Horizontal"> ((... similar as above...)) </StackPanel> </StackPanel> </Grid> </Grid> 

Hope this helps someone else if you get something like this.

+1
source

In order for something in WPF to display a tooltip, it should be clear that testing needs to be done.

In the case of panels, this is done by setting the background color for something other than null (which is the default value for all panels). If you want your panels to be invisible, but still suitable for impact testing, you can use Transparent as the background color.

 <Grid Background="Transparent" ToolTip="This Will Be Shown"> <!-- other stuff --> </Grid> <Grid ToolTip="This Will NOT Be Shown"> <!-- other stuff --> </Grid> 
+9
source

All Articles