[英]Why is my flyout crashing when I try to create a StackPanel with two child elements and assign that to a Flyout?
[英]Create Hints flyout when clicking on help icon
將鼠標懸停在行末或單擊幫助圖標時,我想創建一個提示彈出窗口的WPF效果。 有任何想法嗎? 我嘗試過類似的操作,但是當我單擊“彈出按鈕”時不會激活。
<TextBlock Text="?">
<TextBlock.ContextFlyout>
<Flyout>
<RichTextBlock>
<Paragraph>
This is the help <LineBreak/>
for this row<LineBreak/>
</Paragraph>
</RichTextBlock>
</Flyout>
</TextBlock.ContextFlyout>
</TextBlock>
根據您的要求,您可以像下面這樣在TextBlock
xaml中創建AttachedFlyout
:
<TextBlock Text="?" Tapped="TextBlock_Tapped">
<FlyoutBase.AttachedFlyout>
<Flyout>
<TextBlock x:Name="MyTextBox" Text="You can edit this text by tapping it."/>
</Flyout>
</FlyoutBase.AttachedFlyout>
</TextBlock>
並調用ShowAttachedFlyout
在TextBlock的方法Tapped
事件處理程序。
private void Element_Tapped(object sender, TappedRoutedEventArgs e)
{
FrameworkElement element = sender as FrameworkElement;
if (element != null)
{
FlyoutBase.ShowAttachedFlyout(element);
}
}
您也可以使用ToolTip
來實現。
<TextBlock Text="?">
<ToolTipService.ToolTip>
<ToolTip Content="You can edit this text by tapping it." />
</ToolTipService.ToolTip>
</TextBlock>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.