0
我试图让用户组件可以让您点击TextBlock中的一个单词并对其进行修改。我设法让单词可点击并能够确定我点击了哪个单词。但我也需要知道点击发生的坐标。在TextBlock中点击超链接的获取点(X,Y)
我的代码:
<UserControl
x:Class="wordedit.EditableTextBlock"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:wordedit"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400">
<Grid Name="grid">
<TextBlock Margin="0" Padding="0" LineStackingStrategy="BaselineToBaseline" TextLineBounds="Full" TextWrapping="WrapWholeWords" Name="textBlock">
</TextBlock>
</Grid>
</UserControl>
的C#代码:如何IAM构建的TextBlock
Run r = new Run();
r.Text = words[i];
Hyperlink l = new Hyperlink();
l.Click += L_Click;
l.Inlines.Add(r);
textBlock.Inlines.Add(l);
private void L_Click(Hyperlink sender, HyperlinkClickEventArgs args)
{ // doing some user response here
}
的内嵌由于点击参数任何不提供信息,甚至不允许我设置已处理假。这意味着文本块本身不会触发Tapped事件。
有没有办法,只需要获取坐标?谢谢 !
编辑:我的其他想法。 Iam能够轻松地从Tapped事件中获取X,Y.那么是否有可能将透明元素放在textblock前面作为不可见的画布,并处理事件并将其传递给下面的元素?