In this article we are going to see how to load a Flow document from the Resource dictionary, Describe the style for the FlowdocumentPageViewer and define the Flow Document data there in the resource dictionary along with key name, which is used to reference later using that key.
Now create a reference in the main window by adding the resource dictionary in the window resources.
Code for the main window
Output:
from this article you can see how to use the resource dictionary in the another window.
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<FlowDocument x:Key="doctext">
<Paragraph> <Bold>Mouse Operations</Bold></Paragraph>
<List>
<ListItem><Paragraph>Left Click = Menu options</Paragraph></ListItem>
<ListItem><Paragraph>Right Click = Ok </Paragraph></ListItem>
</List>
<Paragraph><Bold>Keyboard Shortcuts</Bold></Paragraph>
<List>
<ListItem><Paragraph>Ctrl + a = Select All</Paragraph></ListItem>
<ListItem><Paragraph>Ctrl + Click = Item selected</Paragraph></ListItem>
</List>
</FlowDocument>
<Style TargetType="{x:Type FlowDocumentPageViewer}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate
TargetType="{x:Type FlowDocumentPageViewer}">
<AdornerDecorator>
<DocumentPageView></DocumentPageView>
</AdornerDecorator>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Helptext.xaml"></ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid>
<FlowDocumentPageViewer Document="{StaticResource doctext}"></FlowDocumentPageViewer>
</Grid>
Output:
from this article you can see how to use the resource dictionary in the another window.