I need to show a hyperlink on a tooltip. The hyperlink should be clickable. My XAML so far is:
我需要在工具提示上显示一个超链接。超链接应该是可点击的。到目前为止,我的XAML是:
<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://*.com/questions/">http://*.com/questions/</Hyperlink>
</ToolTip>
</Button.ToolTip>
</Button>
Output:
But it is not clickable and hides immediately. I need the link to be clickable.
但它不可点击并立即隐藏。我需要链接是可点击的。
1 个解决方案
#1
5
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.
您必须使用Popup滚动自己的“工具提示”。工具提示并非设计为交互式,因为您正在请求,但弹出窗口可以提供对显示功能的更多控制。
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://*.com/questions/">http://*.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.
而后面的代码只是使用mover over on按钮并从弹出窗口中退出。您必须推导出符合用户要求的显示方法。
private void bttnTarget_MouseLeave(object sender, MouseEventArgs e)
{
tooltip.IsOpen = false;
}
private void bttnTarget_MouseEnter(object sender, MouseEventArgs e)
{
tooltip.IsOpen = true;
}
#1
5
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.
您必须使用Popup滚动自己的“工具提示”。工具提示并非设计为交互式,因为您正在请求,但弹出窗口可以提供对显示功能的更多控制。
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://*.com/questions/">http://*.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.
而后面的代码只是使用mover over on按钮并从弹出窗口中退出。您必须推导出符合用户要求的显示方法。
private void bttnTarget_MouseLeave(object sender, MouseEventArgs e)
{
tooltip.IsOpen = false;
}
private void bttnTarget_MouseEnter(object sender, MouseEventArgs e)
{
tooltip.IsOpen = true;
}