如何处理子文字点击?

时间:2014-04-11 09:34:59

标签: c# xaml windows-phone-8 windows-phone textblock

在Windows Phone中(在Windows Phone 7.1和Windows Phone 8上),在包装文本块中,我希望下划线和可点击的子文本。但是,TextBlock / RichTextBox中的运行没有任何事件。使用WPToolkit的WrapPanel我可以通过将每个单词放在一个单独的TextBlock中来实现所需的包装,但是我无法将TextAlignment设置为Justify。有更好的方法吗?

<TextBlock TextWrapping="Wrap">
    <Run Text="I have a paragraph consisting of multiple lines that I want to be neatly wrapped with just one word that I'll be able to "/>
    <Run TextDecorations="Underline">tap</Run>
</TextBlock>

<toolkit:WrapPanel>
    <TextBlock Text="I "/>
    <TextBlock Text="have "/>
    <TextBlock Text="a paragraph "/>
    <TextBlock Text="consisting "/>
    ...
    <TextBlock Text="able to"/>
    <TextBlock TextDecorations="Underline" Tap="HandleLinkTap" Text="tap"/>
</toolkit:WrapPanel>

1 个答案:

答案 0 :(得分:1)

https://stackoverflow.com/a/15148602/546896是否解决了您的问题? 我知道一点点hackish方式,但仍然看它是否有效。

<RichTextBox TextWrapping="Wrap">
    <Paragraph>
        <Run Text="I have a paragraph consisting of multiple lines that I want to be   neatly wrapped with just one word that I'll be able to " />
        <Hyperlink Click="HandleLinkTap">Tap</Hyperlink>
    </Paragraph>
</RichTextBox>