gpt4 book ai didi

c# - WPF 中工具提示或弹出窗口上的可单击超链接

转载 作者:太空狗 更新时间:2023-10-29 23:06:11 26 4
gpt4 key购买 nike

我需要在工具提示上显示超链接。超链接应该是可点击的。到目前为止,我的 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>

输出:

the output

但它不可点击并立即隐藏。我需要链接可以点击。

最佳答案

您将不得不使用弹出窗口滚动您自己的“工具提示”。工具提示并非设计为按照您的要求进行交互,但弹出窗口可以提供对显示功能的更多控制。

然后您可以通过工具提示服务提供的类似事件(鼠标悬停、鼠标离开等)控制弹出窗口的打开

<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>

后面的代码只是在按钮上使用移动器并从弹出窗口离开。您必须得出自己的显示方法来满足用户的要求。

private void bttnTarget_MouseLeave(object sender, MouseEventArgs e)
{
tooltip.IsOpen = false;
}
private void bttnTarget_MouseEnter(object sender, MouseEventArgs e)
{
tooltip.IsOpen = true;
}

关于c# - WPF 中工具提示或弹出窗口上的可单击超链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35583413/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com