Pro WPF in C# 2008: Windows Presentation Foundation with .NET 3.5, Second Edition

Matthew MacDonald

Author Matthew MacDonald shows you how WPF really works. His no–nonsense, practical advice will get you building high–quality WPF applications quickly and easily.

  • Published on Jul 29 2008
  • Pages 1040
  • Downloaded 224
  • Type PDF
Download
    • Like
    • Love It
    • Awesome
    • Interesting
    • It's Okay
    • Thumbs Down
  • 30k
  • 0

Introduction

The Microsoft Windows Presentation Foundation provides the foundation for building applications and high–quality user experiences in Windows Vista. WPF blends application user interface, documents, and media content to provide richer control, design, and development of the visual aspects of Windows programs.

Author Matthew MacDonald shows you how WPF really works. His no–nonsense, practical advice will get you building high–quality WPF applications quickly and easily. MacDonald will take you through a thorough investigation of the more advanced aspects of WPF, and its relation to other elements of the WinFX stack and the .NET Framework 3.5, to complete your understanding of WPF and C# 2008.

WPFs functionality extends to support for Tablet PCs and other forms of input device, and provides a more modern imaging and printing pipeline, accessibility and UI automation infrastructure, data–driven UI and visualization, as well as the integration points for weaving the application experience into the Windows shell.

What you’ll learn

  • WPF basics: XAML, layout, control essentials, and data flow
  • WPF applications: Navigation, commands, localization, and deployment
  • Advanced controls: Custom controls, menus, toolbars, and trees
  • WPF documents: Text layout, printing, and document packaging
  • Graphics and multimedia: Drawing shapes, sound and video, animation, geometric transformations, and imaging

Who is this book for?

Developers encountering WPF and .NET 3.5 for the first time in their professional lives

Author Information

Matthew MacDonald is an author, educator, and MCSD developer who has a passion for emerging technologies. He is a regular writer for developer journals such as Inside Visual Basic, ASPToday, and Hardcore Visual Studio .NET, and he's the author of several books about programming with .NET, including User Interfaces in VB .NET: Windows Forms and Custom Controls, The Book of VB .NET, and .NET Distributed Applications. In a dimly remembered past life, he studied English literature and theoretical physics. Send e-mail to him with praise, condemnation, and everything in between, to [email protected].

What is in this book

Contents

About the Author
About the Technical Reviewer
Acknowledgments
Introduction

CHAPTER 1 Introducing WPF

Understanding Windows Graphics
                DirectX: The New Graphics Engine
                Hardware Acceleration and WPF
WPF: A Higher-Level API
                Resolution Independence
                The Evolution of WPF
                Windows Forms Lives On
                DirectX Also Lives On
                Silverlight
The Architecture of WPF
                The Class Hierarchy
The Last Word

CHAPTER 2 XAML

Understanding XAML
                Graphical User Interfaces Before WPF
                The Variants of XAML
                XAML Compilation
XAML Basics
                XAML Namespaces
                The Code-Behind Class
Properties and Events in XAML
                Simple Properties and Type Converters
                Complex Properties
                Markup Extensions
                Attached Properties
                Nesting Elements
                Special Characters and Whitespace
                Events
                The Full Eight Ball Example
Using Types from Other Namespaces
                Loading and Compiling XAML
                Code-Only
                Code and Uncompiled XAML
                Code and Compiled XAML
                XAML Only
The Last Word

CHAPTER 3 The Application

The Application Life Cycle
                Creating an Application Object
                Deriving a Custom Application Class
                Application Shutdown
                Application Events
Application Tasks
                Handling Command-Line Arguments
                Accessing the Current Application
                Interacting Between Windows
                Single-Instance Applications
The Last Word

CHAPTER 4 Layout

Understanding Layout in WPF
                The WPF Layout Philosophy
                The Layout Process
                The Layout Containers
Simple Layout with the StackPanel
                Layout Properties
                Alignment
                Margin
                Minimum, Maximum, and Explicit Sizes
The WrapPanel and DockPanel
                The WrapPanel
                The DockPanel
                Nesting Layout Containers
The Grid
                Fine-Tuning Rows and Columns
                Spanning Rows and Columns
                Split Windows
                Shared Size Groups
                The UniformGrid
Coordinate-Based Layout with the Canvas
                Z-Order
                The InkCanvas
Layout Examples
                A Column of Settings
                 Content
                A Modular User Interface
The Last Word

CHAPTER 5 Content

Understanding Content Controls
                The Content Property
                Aligning Content
                The WPF Content Philosophy
Specialized Containers
                The ScrollViewer
                The GroupBox and TabItem: Headered Content Controls
                The Expander
Decorators
                The Border
                The Viewbox
The Last Word

CHAPTER 6 Dependency Properties and Routed Events

Understanding Dependency Properties
                Defining and Registering a Dependency Property
                How WPF Uses Dependency Properties
Understanding Routed Events
                Defining and Registering a Routed Event
                Attaching an Event Handler
                Event Routing
WPF Events
                Lifetime Events
                Input Events
                Keyboard Input
                Mouse Input
The Last Word

CHAPTER 7 Classic Controls

The Control Class
                Background and Foreground Brushes
                Fonts
                Mouse Cursors
Content Controls
                Labels
                Buttons
                Tooltips
Text Controls
                Multiple Lines of Text
                Text Selection
                Miscellaneous TextBox Features
                The PasswordBox
List Controls
                The ListBox
                The ComboBox
Range-Based Controls
                The Slider
                The ProgressBar
The Last Word

CHAPTER 8 Windows

The Window Class
                Showing a Window
                Positioning a Window
                Saving and Restoring Window Location
Window Interaction
                Window Ownership
                The Dialog Model
                Common Dialog Boxes
Nonrectangular Windows
                A Simple Shaped Window
                A Transparent Window with Shaped Content
                Moving Shaped Windows
                Resizing Shaped Windows
Vista-Style Windows
                Using the Windows Vista Glass Effect
                The Task Dialog and File Dialog Boxes
The Last Word

CHAPTER 9 Pages and Navigation

Understanding Page-Based Navigation

Page-Based Interfaces
                A Simple Page-Based Application with Nav
                The Page Class
                Hyperlinks
                Hosting Pages in a Frame
                Hosting Pages in Another Page
                Hosting Pages in a Web Browser
The Page History
                A Closer Look at URIs in WPF
                Navigation History
                Maintaining Custom Properties
The Navigation Service
                Programmatic Navigation
                Navigation Events
                Managing the Journal
                Adding Custom Items to the Journal
                Page Functions
XAML Browser Applications
                XBAP Requirements
                Creating an XBAP
                Deploying an XBAP
                Updating an XBAP
                XBAP Security
                Full-Trust XBAPs
                Combination XBAP/Stand-Alone Applications
                Coding for Different Security Levels
                Embedding an XBAP in a Web Page
The Last Word

CHAPTER 10 Commands

Understanding Commands
The WPF Command Model
                The ICommand Interface
                The RoutedCommand Class
                The RoutedUICommand Class
                The Command Library
Executing Commands
                Command Sources
                Command Bindings
                Using Multiple Command Sources
                Fine-Tuning Command Text
                Invoking a Command Directly
                Disabling Commands
                Controls with Built-in Commands
Advanced Commands
                Custom Commands
                Using the Same Command in Different Places
                Using a Command Parameter
                Tracking and Reversing Commands
The Last Word

CHAPTER 11 Resources

Assembly Resources
                Adding Resources
                Retrieving Resources
                Pack URIs
                Content Files
Localization
                Building Localizable User Interfaces
                Preparing an Application for Localization
                The Translation Process
Object Resources
                The Resources Collection
                The Hierarchy of Resources
                Static and Dynamic Resources
                Nonshared Resources
                Accessing Resources in Code
                Application Resources
                System Resources
                Organizing Resources with Resource Dictionaries
                Sharing Resources Between Assemblies
The Last Word

CHAPTER 12 Styles

Style Basics
                Creating a Style Object
                Setting Properties
                Attaching Event Handlers
                The Many Layers of Styles
                Automatically Applying Styles by Type
Triggers
                A Simple Trigger
                An Event Trigger
Last Word

CHAPTER 13 Shapes, Transforms, and Brushes

Understanding Shapes
                The Shape Classes
                Rectangle and Ellipse
                Sizing and Placing Shapes
                Sizing Shapes Proportionately with a Viewbox
                Line
                Polyline
                Polygon
                Line Caps and Line Joins
                Dashes
                Pixel Snapping
Transforms
                Transforming Shapes
                Transforming Elements
Better Brushes
                The LinearGradientBrush
                The RadialGradientBrush
                The ImageBrush
                A Tiled ImageBrush
                The VisualBrush
                Opacity Masks
Bitmap Effects
                Blurs
                Beveled Edges
                Embossed Edges
                Glows and Shadows
The Last Word

CHAPTER 14 Geometries, Drawings, and Visuals

Paths and Geometries
                Line, Rectangle, and Ellipse Geometries
                Combining Shapes with GeometryGroup
                Fusing Geometries with CombinedGeometry
                Curves and Lines with PathGeometry
                The Geometry Mini-Language
                Clipping with Geometry
Drawings
                Displaying a Drawing
                Exporting Clip Art
Visuals
                Drawing Visuals
                Wrapping Visuals in an Element
                Hit Testing
                Complex Hit Testing
The Last Word

CHAPTER 15 Control Templates

Understanding Logical Trees and Visual Trees
Understanding Templates
                The Chrome Classes
                Dissecting Controls
Creating Control Templates
                A Simple Button
                Template Bindings
                Template Triggers
Organizing Template Resources
                Refactoring the Button Control Template
                Applying Templates with Styles
                Applying Templates Automatically
                User-Selected Skins
Building More Complex Templates
                Multipart Templates
                Control Templates in an ItemsControl
                Modifying the Scroll Bar
                Creating a Custom Window
                The Simple Styles
The Last Word

CHAPTER 16 Data Binding

Data Binding Basics
                Binding to the Properties of an Element
                Creating Bindings with Code
                Multiple Bindings
                Binding Direction
                Binding Updates
                Binding to Objects That Aren’t Elements
Binding to a Database with Custom Objects
                Building a Data Access Component
                Building a Data Object
                Displaying the Bound Object
                Updating the Database
                Change Notification
Binding to a Collection of Objects
                Displaying and Editing Collection Items
                Inserting and Removing Collection Items
                Binding to the ADO.NET Objects
                Binding to a LINQ Expression
Data Conversion
                Formatting Strings with a Value Converter
                Creating Objects with a Value Converter
                Applying Conditional Formatting
                Evaluating Multiple Properties
Validation
                Validation in the Data Object
                Custom Validation Rules
                Reacting to Validation Errors
                Getting a List of Exceptions
                Showing a Different Error Indicator
The Last Word

CHAPTER 17 Data Templates, Data Views, and Data Providers

Data Binding Redux
                Data Templates
                Separating and Reusing Templates
                More Advanced Templates
                Varying Templates
                Template Selectors
                Templates and Selection
                Style Selectors
                Changing Item Layout
Data Views
                Retrieving a View Object
                Filtering Collections
                Filtering the DataTable
                Sorting
                Grouping
                Creating Views Declaratively
                Navigating with a View
Data Providers
                The ObjectDataProvider
                The XmlDataProvider
The Last Word

CHAPTER 18 Lists, Trees, Toolbars, and Menus

The ItemsControl Class
                The ComboBox
                A ListBox with Check Boxes or Radio Buttons
The ListView
                Creating Columns with the GridView
                Resizing Columns
                Cell Templates
                Creating a Custom View
The TreeView
                A Data-Bound TreeView
                Binding a DataSet to a TreeView
                Just-in-Time Node Creation
Menus
                The Menu Class
                Menu Items
                The ContextMenu Class
                Menu Separators
Toolbars and Status Bars
                The ToolBar
                The StatusBar
The Last Word

CHAPTER 19 Documents

Understanding Documents
Flow Documents
                The Flow Elements
                Formatting Content Elements
                Constructing a Simple Flow Document
                Block Elements
                Inline Elements
                Interacting with Elements Programmatically
                Text Justification
Read-Only Flow Document Containers
                Zooming
                Pages and Columns
                Loading Documents from a File
                Printing
Editing a Flow Document
                Loading a File
                Saving a File
                Formatting Selected Text
                Getting Individual Words
Fixed Documents
Annotations
                The Annotation Classes
                Enabling the Annotation Service
                Creating Annotations
                Examining Annotations
                Reacting to Annotation Changes
                Storing Annotations in a Fixed Document
                Customizing the Appearance of Sticky Notes
Last Word

CHAPTER 20 Printing

Basic Printing
                Printing an Element
                Transforming Printed Output
                Printing Elements Without Showing Them
                Printing a Document
                Manipulating the Pages in a Document Printout
Custom Printing
                Printing with the Visual Layer Classes
                Custom Printing with Multiple Pages
Print Settings and Management
                Maintaining Print Settings
                Printing Page Ranges
                Managing a Print Queue
Printing Through XPS
                Creating an XPS Document for a Print Preview
                Printing Directly to the Printer via XPS
                Asynchronous Printing
The Last Word

CHAPTER 21 Animation

Understanding WPF Animation
                Timer-Based Animation
                Property-Based Animation
Basic Animation
                The Animation Classes
                Animations in Code
                Simultaneous Animations
                Animation Lifetime
                The Timeline Class
Declarative Animation and Storyboards
                The Storyboard
                Event Triggers
                Overlapping Animations
                Simultaneous Animations
                Controlling Playback
                Monitoring Progress
                Desired Frame Rate
Animation Types Revisited
                Animating Transforms
                Animating Brushes
                Key Frame Animation
                Path-Based Animation
                Frame-Based Animation
The Last Word

CHAPTER 22 Sound and Video

Playing WAV Audio
                The SoundPlayer
                The SoundPlayerAction
                System Sounds
The MediaPlayer
                The MediaElement
                Playing Audio Programmatically
                Handling Errors
                Playing Audio with Triggers
                Playing Multiple Sounds
                Changing Volume, Balance, Speed, and Position
                Synchronizing an Animation with Audio
                Playing Video
                Video Effects
Speech
                Speech Synthesis
                Speech Recognition
The Last Word

CHAPTER 23 3-D Drawing

3-D Drawing Basics
                The Viewport
                3-D Objects
                The Camera
Deeper into 3-D
                Shading and Normals
                More Complex Shapes
                Model3DGroup Collections
                Materials Revisited
                Texture Mapping
Interactivity and Animations
                Transforms
                Rotations
                A Fly Over
                The Trackball
                Hit Testing
                2-D Elements on 3-D Surfaces
The Last Word

CHAPTER 24 Custom Elements

Understanding Custom Elements in WPF
Building a Basic User Control
                Defining Dependency Properties
                Defining Routed Events
                Adding Markup
                Using the Control
                Command Support
                A Closer Look at User Controls
Lookless Controls
                Refactoring the Color Picker Code
                Refactoring the Color Picker Markup
                Streamlining the Control Template
                Theme-Specific Styles and the Default Style
Extending an Existing Control
                Understanding Masked Edit Controls
                Mask Syntax
                The MaskedTextProvider
                Implementing a WPF Masked Text Box
                Improving the MaskedTextBox
Custom Panels
                The Two-Step Layout Process
                The Canvas Clone
                A Better Wrapping Panel
Custom-Drawn Elements
                The OnRender() Method
                Evaluating Custom Drawing
                A Custom-Drawn Element
                A Custom Decorator
The Last Word

CHAPTER 25 Interacting with Windows Forms

Assessing Interoperability
                Missing Features in WPF
Mixing Windows and Forms
                Adding Forms to a WPF Application
                Adding WPF Windows to a Windows Forms Application
                Showing Modal Windows and Forms
                Showing Modeless Windows and Forms
                Visual Styles for Windows Forms Controls
                Windows Forms Classes That Don’t Need Interoperability
Creating Windows with Mixed Content
                WPF and Windows Forms “Airspace”
                Hosting Windows Forms Controls in WPF
                WPF and Windows Forms User Controls
                Hosting WPF Controls in Windows Forms
                Access Keys, Mnemonics, and Focus
                Property Mapping
The Last Word

CHAPTER 26 Multithreading and Add-Ins

Multithreading
                The Dispatcher
                The DispatcherObject
                The BackgroundWorker
Application Add-Ins
                The Add-in Pipeline
                An Application That Uses Add-Ins
                Interacting with the Host
                Visual Add-Ins
The Last Word

CHAPTER 27 ClickOnce Deployment

Application Deployment
                Understanding ClickOnce
                The ClickOnce Installation Model
                ClickOnce Limitations
A Simple ClickOnce Publication
                Choosing a Location
                Deployed Files
                Installing a ClickOnce Application
                Updating a ClickOnce Application
ClickOnce Options
                Publish Version
                Updates
                Publish Options
The Last Word

INDEX

Note:

Mindcracker Network accepts no liability for providing the customer with the hard copy of the book purchased. Mindcracker is not responsible for any dispute relating to the above. All eBooks listed in this section are in "PDF" Format. Contact [email protected] for further assistant.