WPF交互式内容(按钮,超链接等)在FlowDocument中永远无法使用

我一定在这里想念什么。我已经尝试了所有可能的方法来使任何在FlowDocument中都可以单击。

我已经尝试过<Hyperlink>(以及通过XAML和纯代码背后分配NavigateUriRequestNavigate甚至Hyperlink.Click事件的所有可能方法),并且我尝试将按钮放在<BlockUIContainer>上,但这仍然无效。

内容正确呈现,但是单击它不会执行任何操作。

我还尝试了删除所有Style选项,因此它仅是其中包含'stuff'的FlowDocument,并且尝试将RichTextBox设置为IsReadOnly=True/False。但是没有运气!

以下示例。 <Hyperlink>在哪里,我已经尝试了所有可能,例如<BlockUIContainer>等。最终结果始终是元素以正确的方式呈现,但单击根本没有结果。

//XAML
 <RichTextBox IsReadOnly="True">
     <FlowDocument>
         <Paragraph>
             1.1.3 Course technology requirements
         </Paragraph>
         <Paragraph>
             <Run>
                 access to an internet connection and a standard,modern web 
                 browser are the only necessary requirements of the course. 
                 If you are using an old or outdated browser,such as Internet 
                 Explorer,you may need to update. We recommend
             </Run>

             <Hyperlink x:Name="GoogleChromeLink" 
                        NavigateUri="https://www.google.com/chrome/" 
                        RequestNavigate="Hyperlink_RequestNavigate" >
                Google Chrome.
            </Hyperlink>

        </Paragraph>
    </FlowDocument>
</RichTextBox> 

// C#

private void Hyperlink_RequestNavigate(object sender,RequestNavigateEventArgs e)
{
    Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
    e.Handled = true;
}

任何指针将不胜感激。谢谢。

zhao_xunze 回答:WPF交互式内容(按钮,超链接等)在FlowDocument中永远无法使用

此解决方案节省了一天的时间:https://stackoverflow.com/a/6146387/5801881

我需要将IsDocumentEnabled="True"添加到RichTextBox元素中:

<RichTextBox IsDocumentEnabled="True" IsReadOnly="True">
本文链接:https://www.f2er.com/3169281.html

大家都在问