簡體   English   中英

如何從后面的代碼將Document屬性綁定到FlowDocumentScrollViewer?

[英]How to bind the Document property to FlowDocumentScrollViewer from code behind?

我如何將Document屬性綁定到FlowDocumentScrollViewer,如XAML中所示:

<FlowDocumentScrollViewer Document="{Binding ElementName=Element, Path=Text, Converter={StaticResource TextToFlowDocumentConverter}}"/>

但是在后面的代碼中?

我不確定這是否可以完全解決您要嘗試執行的操作,但是如果您在XAML中為FlowDocumentScrollViewer命名,如下所示:

<FlowDocumentScrollViewer Name="FlowDocViewer" />

您可以在后面的代碼中設置Document屬性。

像這樣:

 public MyWindow() // constructor, in case this is confusing
    {
        InitializeComponent();
        FlowDocViewer.Document = SomeDocumentObject;
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM