だから私はこのXAMLを.xamlファイルに持っています
<StackPanel>
<Button Width="200" Height="30" Content="Change Words"
Click="Button_Click"/>
<FlowDocumentReader
ViewingMode="Scroll" Zoom="90"
Focusable="True"
Background="White"
IsFindEnabled="True"
IsPageViewEnabled="True"
IsScrollViewEnabled="True"
x:Name="FDR"
Document="{Binding Path=WordDocument}"
Width="400" Height="400">
</FlowDocumentReader>
</StackPanel>
コードビハインドでは、ロード時に、
public partial class Window1 : Window
{
MyDoc _myDoc = null;
FlowDocument _theFlowDocument;
public Window1()
{
InitializeComponent();
_myDoc = new MyDoc().Create(); // Create returns MyDoc, that has a WordDocument property with some FlowDocument contents
this.DataContext = _myDoc ;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
_myDoc.WordDocument = _myDoc.CreateFlowDocument("Now it's changed");
}
}
ボタンをクリックすると、WordDocument の内容が変更されます。CreateFlowDocument は、渡された文字列を使用して Paragraph と Run を作成します。
ボタンをクリックすると、FlowDocumentReader は変更されたコンテンツを表示しませんが、WordDocument プロパティにバインドしました。
私は何を間違っていますか?