Flow Documents are typically defined using Extensible Application Markup Language (XAML), the XML-based standard markup language. XAML is particularly intuitive for Flow Documents, mainly because of the similarity to HTML. The following Flow Document sample creates a single paragraph of text with simple bold formatting applied to a few words:
<FlowDocument FontSize="14" FontFamily="Georgia">
<Paragraph>
<TextBlock>
All about Resources in WPF
TextBlock>
<TextBlock>
This blogpost talks about what resources are in WPF.
TextBlock>
<TextBlock>
What this blog post doesn't talk about however, is databinding.
TextBlock>
Paragraph>
FlowDocument>
How to Save or Load a Flowdocument Embedded Images
There is a way to save and load a flow document including all embedded images by putting them into a xaml package.
The following sample shows how to do this
// Save
var source = new FlowDocument();
var range = new TextRange(source.ContentStart, source.ContentEnd);
using (var stream = File.Create("output.pak"))
{
range.Save(stream, DataFormats.XamlPackage);
}
// Load
using(var stream = File.OpenRead("output.pak"))
{
var target = new FlowDocument();
var range = new TextRange(target.ContentStart, target.ContentEnd);
range.Load(stream, DataFormats.XamlPackage);
}
For more you can read
0 التعليقات:
إرسال تعليق