DocumentViewer Styling Sample

The DocViewerStyling sample shows how through the use of styles you can change the appearance and behavior of a DocumentViewer control. When executed, the sample displays a menu bar with "File" and "Style" options. When "File | Open..." is selected, a "File Open..." dialog displays enabling the user to browse and select an XpsDocument file to open (a sample XPS document is provided). When a document is opened, its content is displayed in the DocumentViewer control of the main application window. By selecting different options under the "Style" menu, you can select different styles to change the appearance and behavior of the DocumentViewer control.

The DocViewerStyling sample consists of four source files:

  • App.xaml - XAML resources and DocumentViewer styles that are used by the application.

  • App.xaml.cs - Code-behind for creating and displaying the application window.

  • Window1.xaml - XAML declarations that define the elements of the application window: main menu, menu commands, and DocumentViewer control.

  • Window1.xaml.cs - Code-behind supporting the user interface for the "File" and "Style" menu commands.

This sample demonstrates a specific feature of the Windows Presentation Foundation (WPF) and, consequently, does not follow application development best practices. For comprehensive coverage of WPF and Microsoft .NET Framework application development best practices, refer to the following as appropriate:

Accessibility - Accessibility Best Practices

Security - Windows Presentation Foundation Security

Localization - WPF Globalization and Localization Overview

Download sample

  • Install the Windows Software Development Kit (SDK) and open its build environment command window. On the Start menu, point to All Programs, Microsoft Windows SDK, and then click CMD Shell.

  • Download the sample, usually from the software development kit (SDK) documentation, to your hard disk drive.

  • To build the sample from the build environment command window, go to the source directory of the sample. At the command prompt, type MSBUILD.

  • To build the sample in Microsoft Visual Studio, load the sample solution or project file and then press CTRL+SHIFT+B.

  • To run the compiled sample with debugging in Visual Studio, press F5.

  • To run the sample from a CMD Shell command window, execute the .exe file located in the source folder of the sample.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2015 Microsoft