I need to show a hyperlink on a tooltip. The hyperlink should be clickable. My XAML so far is:
<Button Content="Click..!!"
Height="23"
HorizontalAlignment="Left"
Margin="191,108,0,0"
Name="button1"
VerticalAlignment="Top"
Width="75" >
<Button.ToolTip>
<ToolTip StaysOpen="True"
ToolTipService.BetweenShowDelay="5000"
ToolTipService.ShowDuration="5000"
ToolTipService.InitialShowDelay="5000">
<Hyperlink NavigateUri="http://stackoverflow.com/questions/">http://stackoverflow.com/questions/</Hyperlink>
</ToolTip>
</Button.ToolTip>
</Button>
Output:
But it is not clickable and hides immediately. I need the link to be clickable.
You will have to roll your own "Tooltip" using the Popup. Tooltips are not designed to be interactive as you are requesting but popup windows are and offer more control over the displaying functionality.
You can then control the popup opening through similar events that the tooltip service provides (mouse over, mouse leave etc.)
<Button x:Name="bttnTarget" MouseEnter="bttnTarget_MouseEnter" Content="Click..!!" Height="23" HorizontalAlignment="Left" Margin="191,108,0,0" VerticalAlignment="Top" Width="75" />
<Popup x:Name="tooltip" PlacementTarget="{Binding ElementName=bttnTarget}" MouseLeave="bttnTarget_MouseLeave" Placement="Bottom">
<StackPanel>
<TextBlock>
<Hyperlink NavigateUri="http://stackoverflow.com/questions/">http://stackoverflow.com/questions/</Hyperlink>
</TextBlock>
</StackPanel>
</Popup>
And the code behind is just using mover over on button and leave from popup. You would have to derive your own showing methodology that meets the users requirements.
private void bttnTarget_MouseLeave(object sender, MouseEventArgs e)
{
tooltip.IsOpen = false;
}
private void bttnTarget_MouseEnter(object sender, MouseEventArgs e)
{
tooltip.IsOpen = true;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With