首页 > 解决方案 > 如何在 Flyout (XAML) 中使 TextBlock 可选?

问题描述

我的 XAML 代码:

<AppBarButton>
    <AppBarButton.Flyout>
        <Flyout>
            <TextBlock Text="Text is not selectable here" IsTextSelectionEnabled="True"/>
        </Flyout>
    </AppBarButton.Flyout>
</AppBarButton>

尽管我设置了 IsTextSelectionEnabled - 文本在 Flyout 中不可选择。是否可以使文本可选?我试过 RichTextBlock - 它也不起作用。

标签: xamluwp

解决方案


您可以尝试在 AppBarButton 上将AllowFocusOnInteraction属性设置为 true 以获得焦点。

<AppBarButton AllowFocusOnInteraction="True">
    <AppBarButton.Flyout>
        <Flyout>
            <TextBlock Text="Text is not selectable here" IsTextSelectionEnabled="True"/>
        </Flyout>
    </AppBarButton.Flyout>
</AppBarButton>   

推荐阅读