15.02.2015 Views

C# 4 and .NET 4

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

37<br />

Creating Documents with WPf<br />

WhaT ’ s in This ChaPTer<br />

➤<br />

➤<br />

➤<br />

➤<br />

Creating fl ow documents<br />

Creating fi xed documents<br />

Creating XPS documents<br />

Printing documents<br />

Creating documents is a large part of WPF. The namespace System.Windows.Documents<br />

supports creating fl ow <strong>and</strong> fi xed documents. This namespace contains elements with which you can<br />

have a rich Word - like experience with fl ow documents, <strong>and</strong> create WYSIWYG fi xed documents.<br />

Flow documents are geared towards screen reading; the content of the document is arranged based<br />

on the size of the window, <strong>and</strong> the fl ow of the document changes if the window is resized. Fixed<br />

d o c u m e n t s are mainly used for printing <strong>and</strong> page - oriented content <strong>and</strong> the content is always arranged<br />

in the same way.<br />

This chapter teaches you how to create <strong>and</strong> print fl ow <strong>and</strong> fi xed documents, <strong>and</strong> covers the<br />

namespaces System.Windows.Documents , System.Windows.Xps <strong>and</strong> System.IO.Packaging .<br />

TeXT elemenTs<br />

To build the content of documents, you need document elements. The base class of these elements is<br />

TextElement . This class defi nes common properties for font settings, foreground <strong>and</strong> background,<br />

<strong>and</strong> text effects. TextElement is the base class for the classes Block <strong>and</strong> Inline whose functionality<br />

is explored in the following sections.<br />

fonts<br />

An important aspect of text is the look of the text <strong>and</strong> thus the font. With the TextElement , the<br />

font can be specifi ed with the properties FontWeight , FontStyle , FontStretch , FontSize , <strong>and</strong><br />

FontFamily .<br />

➤<br />

Predefi ned FontWeight values are defi ned by the FontWeights class, which offers values such<br />

as UltraLight , Light , Medium , Normal , Bold , UltraBold , <strong>and</strong> Heavy .<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!