Kat*_*iam 5 c# wpf xaml tooltip
我需要在工具提示上显示一个超链接.超链接应该是可点击的.到目前为止,我的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://stackoverflow.com/questions/">http://stackoverflow.com/questions/</Hyperlink>
</ToolTip>
</Button.ToolTip>
</Button>
Run Code Online (Sandbox Code Playgroud)
输出:
但它不可点击并立即隐藏.我需要链接可点击.
您必须使用弹出窗口滚动自己的"工具提示".工具提示并非设计为交互式,因为您正在请求,但弹出窗口可以提供对显示功能的更多控制.
然后,您可以通过工具提示服务提供的类似事件来控制弹出窗口(鼠标悬停,鼠标离开等)
<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>
Run Code Online (Sandbox Code Playgroud)
而后面的代码只是使用移动器上的按钮并从弹出窗口离开.您必须推导出符合用户要求的显示方法.
private void bttnTarget_MouseLeave(object sender, MouseEventArgs e)
{
tooltip.IsOpen = false;
}
private void bttnTarget_MouseEnter(object sender, MouseEventArgs e)
{
tooltip.IsOpen = true;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2768 次 |
| 最近记录: |