Try adding the <ToolTip> element:
. . .
<CheckBox.ToolTip>
<ToolTip>
<StackPanel>
. . .
</StackPanel>
</ToolTip>
</CheckBox.ToolTip>
. . .
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am trying to bind the tooltip foreground in the textblock present inside the stackpanel for displaying the tooltip text. But the binding doesnt work properly in the textblock ie.. tooltip foreground is not applied.Here is the snippet which is provided below.
MainWindow.xaml
<Grid>
<CheckBox Grid.Row="5" Grid.Column="1" HorizontalAlignment="Center" Margin="0,4,10,0" VerticalAlignment="Center" IsChecked="{Binding AutoAdd, Mode=TwoWay}">
<CheckBox.ToolTip>
<StackPanel>
<TextBlock Foreground="{Binding Path=Foreground, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type ToolTip}}}" FontWeight="Bold" FontSize="14" Margin="0,0,0,5">Automatically Add To Path</TextBlock>
<TextBlock Foreground="{Binding Path=Foreground, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type ToolTip}}}">
If this path is associated with the primary configuration,
<LineBreak />
automatically add newly instantiated optical elements to the end of the path.
</TextBlock>
<Border BorderBrush="Silver" BorderThickness="0,1,0,0" Margin="0,8" />
<WrapPanel>
<Image Margin="0,0,5,0" />
<TextBlock Foreground="{Binding Path=Foreground, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type ToolTip}}}" FontStyle="Italic">Press F1 for more help</TextBlock>
</WrapPanel>
</StackPanel>
</CheckBox.ToolTip>
</CheckBox>
</Grid>
So please provide me a solution for this issue.
Regards,
Hari Prasad
Try adding the <ToolTip> element:
. . .
<CheckBox.ToolTip>
<ToolTip>
<StackPanel>
. . .
</StackPanel>
</ToolTip>
</CheckBox.ToolTip>
. . .
In the xaml , there are two ways to set ToolTip for CheckBox. One is to define a tooltip by assigning container/control
to the ToolTip property, like what you did. And the other is to define a tooltip by assigning a ToolTip object
to the ToolTip property, like what Viorel-1 did. You can refer to here for more details. You can set the ToolTip's Foreground in the ToolTip object
like below shown:
<CheckBox Grid.Row="5" Grid.Column="1" HorizontalAlignment="Center" Margin="0,4,10,0" VerticalAlignment="Center" IsChecked="{Binding AutoAdd, Mode=TwoWay}">
<CheckBox.ToolTip>
<ToolTip Foreground="BlueViolet">
<StackPanel>
<TextBlock Foreground="{Binding Path=Foreground, Mode=TwoWay, RelativeSource={RelativeSource AncestorType={x:Type ToolTip}}}"
FontWeight="Bold" FontSize="14" Margin="0,0,0,5">Automatically Add To Path</TextBlock>
<TextBlock Foreground="{Binding Path=Foreground, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type ToolTip}}}">
If this path is associated with the primary configuration,
<LineBreak />
automatically add newly instantiated optical elements to the end of the path.
</TextBlock>
<Border BorderBrush="Silver" BorderThickness="0,1,0,0" Margin="0,8" />
<WrapPanel>
<Image Margin="0,0,5,0" />
<TextBlock Foreground="{Binding Path=Foreground, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type ToolTip}}}"
FontStyle="Italic">Press F1 for more help</TextBlock>
</WrapPanel>
</StackPanel>
</ToolTip>
</CheckBox.ToolTip>
</CheckBox>
If I misunderstand your question,please point out.
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.