0
我使用RichTextBox控件面临challange:如何检索里面的控件(按钮)的RichTextBox内容?
我能够成功段落添加到它在设计时按钮就好了,见下面的XAML:
<RichTextBox x:Name="rtxtStep" HorizontalAlignment="Left" Height="207" Margin="10,32,0,0" VerticalAlignment="Top" Width="427" IsDocumentEnabled="True" KeyUp="richTextBox_KeyUp">
<FlowDocument>
<Section FontSize="15">
<Paragraph>
Click on this:
<Hyperlin k NavigateUri="http://stackoverflow.com">stackoverflow</Hyperlin k>
</Paragraph>
<Paragraph>
<Button Click="Button_Click" Width="143" >Also Click On This</Button>
<Button Click="Button_Click" Width="143" >button 2</Button>
</Paragraph>
</Section>
</FlowDocument>
</RichTextBox>
,我能够检索从我的代码的文字就好了,见下图:
private void richTextBox_KeyUp(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
TextRange txtrContent = new TextRange(rtxtStep.Document.ContentStart, rtxtStep.Document.ContentEnd);
string allContent = txtrContent.Text;
}
}
返回:
"Click on this: stackoverflow\r\n \r\n\r\n"
问题是,我如何检索按钮以及文本?