我有一个这样的流文档:
var mcFlowDoc = new FlowDocument();
var para = new Paragraph();
para.Inlines.Add(textBlock1);
para.Inlines.Add(textBlock2);
para.Inlines.Add(textBlock3);
mcFlowDoc.Blocks.Add(para);
richTextBox1.Document = mcFlowDoc;
我需要一个事件来触发鼠标点击文本块:
<RichTextBox Margin="10,10,230,12" Name="richTextBox1" FontFamily="Simplified Arabic" FontSize="16" IsReadOnly="True" IsReadOnlyCaretVisible="False" ForceCursor="False" FlowDirection="RightToLeft" VerticalScrollBarVisibility="Auto">
<RichTextBox.Resources>
<Style TargetType="Run">
<EventSetter Event="MouseLeftButtonDown" Handler="Run_Click" />
</Style>
<Style TargetType="TextBlock">
<EventSetter Event="MouseLeftButtonDown" Handler="TextBlock_Click" />
</Style>
</RichTextBox.Resources>
</RichTextBox>
void TextBlock_Click(object sender, MouseButtonEventArgs e)
{
TextBlock tb = sender as TextBlock;
}
Run 的事件处理程序被调用并正常工作(在 flowdocument 中更改内联),但 TextBlock 的事件处理程序不是。
我究竟做错了什么?谢谢