I want to add a flyout to my TextBlock
, and when I select the text in the TextBlock, the flyout will show up at the selected (kind of like Reading Mode in Microsoft Edge, when you select the text in reading mode, there will be a flyout show the word's definition). But I don't know how. I've tried using the SelectionChanged
, but the parameters that this event passes don't have an position that I can use to set the flyout
. So how can I do that?
Besides, I'm wondering what SelectionFlyout
is for? I thought it could help me.
Here was my code:
<TextBlock x:Name="webviewtest" Grid.Row="1" Text="This is a select-flyout test." FontSize="300" IsTextSelectionEnabled="true" >
<TextBlock.SelectionFlyout>
<Flyout>
<TextBlock Text="this is the flyout"></TextBlock>
</Flyout>
</TextBlock.SelectionFlyout>
</TextBlock>
And when I selected text, the flyout never showed up. It's obviously that I have been using it wrong. So I checked the Microsoft Docs and it said
Gets or sets the flyout that is shown when text is selected, or null if no flyout is shown.
And I can't find any samples about this online.