Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WPF处理FlowDocument内的链接_Wpf_Data Binding_Mvvm_Flowdocument - Fatal编程技术网

WPF处理FlowDocument内的链接

WPF处理FlowDocument内的链接,wpf,data-binding,mvvm,flowdocument,Wpf,Data Binding,Mvvm,Flowdocument,我正在使用WPF构建简单的字典应用程序 我使用MVVM模式、数据绑定和FlowDocument向用户显示单词 UI由两个控件组成:ListBox和FlowDocumentScrollViewer 字典数据来自XML文件,该字符串的格式可能如下所示 <b>Word</b> - Some description. Another <i>description</i>. Reference <ref id="123">related word

我正在使用WPF构建简单的字典应用程序

我使用MVVM模式、数据绑定和FlowDocument向用户显示单词

UI由两个控件组成:ListBox和FlowDocumentScrollViewer

字典数据来自XML文件,该字符串的格式可能如下所示

<b>Word</b> - Some description. Another <i>description</i>. Reference <ref id="123">related word</ref>
Word-一些描述。另一种描述。参照词
未定义HTML和引用元素的顺序

我解析HTML字符串,将其转换为XAML,然后从XAML创建FlowDocument对象,并将其绑定到FlowDocumentScrollViewer控件的Document属性

当我需要链接ref.元素时,问题就出现了。(我的要求是,当用户单击引用链接时,在列表框控件中选择引用的单词并在FlowDocumentScrollViewer中显示)

我的问题是,有一种方法可以动态创建“超链接”样式的控件(附带事件或命令),将用户带到字典中引用的单词


有可能解决这个问题吗?

有一个超链接文本元素,它有一个命令属性和一个单击事件。它的行为很像一个按钮,但它在FlowDocuments中使用。您可以使用任何一种方法来实现您所追求的目标,但我倾向于使用命令。特别是如果您使用MVVM模式实现此功能,因为您已经标记了…

超链接文本元素具有命令属性和单击事件。它的行为很像一个按钮,但它在FlowDocuments中使用。您可以使用任何一种方法来实现您所追求的目标,但我倾向于使用命令。特别是如果您正在使用MVVM模式实现此功能,正如您所标记的…

感谢您让它发挥作用。Hyperlink+命令解决了此问题。感谢您让它正常工作。Hyperlink+命令解决了这个问题。