Introduction
Overview
Welcome to Practical WPF Charts and Graphics. This book will provide all the tools you need to
develop professional chart and graphics applications using the Windows Presentation Foundation
(WPF) and C# based on the .NET Framework. I hope this book will be useful for WPF and C#
programmers of all skill levels.
We’ve all heard the saying “A picture’s worth a thousand words.” Charts and graphics play a very
important role in every Windows application. They make data easier to understand, add interest to
reports, and have wide applications in our daily life. The scientific, engineering, and mathematics
community always has a need to present data and results graphically. Microsoft’s .NET platform with C#
and WPF is one of the few and best development tools available for providing the computational
capabilities both to generate data as a simulation engine and to display it in a variety of graphical
representations based on the WPF graphics capability.
As a C# programmer, you are probably already familiar with Windows Forms, the mature and
full-featured development tool. Windows Forms is built on top of the .NET Framework and uses the
Windows Application Programming Interface (API) to create the visual appearance of standard user
interface elements. It provides all kinds of tools for laying out windows, menus, dialogs, and controls.
You can also develop graphics applications based on Windows Forms using the Graphical Device
Interface (GDI+). However, creating a feature-rich graphics application using Windows Forms can be a
difficult and tedious task. For example, Windows Forms provides no tools for creating three-dimensional
(3D) graphics applications. Even a 3D point, the simplest of 3D graphics objects, must be defined first in
a suitable 3D coordinate system before it can be used as a 3D graphics object.
WPF changes the landscape of graphics programming completely. At first, you might think that
WPF just provides another way to create windows, menus, dialogs, and controls. However, WPF has
much more to offer than any other Windows programming framework. It integrates three basic
Windows elements — text, controls, and graphics — into a single programming model and puts these
three elements in the same element tree in the same manner.
Without WPF, developing a graphics application would involve a number of different
technologies, ranging from GDI/GDI+ for 2D graphics to Direct3D or OpenGL for 3D graphics. WPF, on
the contrary, is designed as a single model for graphics application development, providing seamless
integration between such services within an application. Similar constructs can be used for creating
animations, data binding, and 3D models.
To take further advantage of new, powerful graphics hardware technologies, WPF implements a
vector-based graphics model. This allows for graphics to be scaled based on screen-specific resolution
without the loss of image quality, something impossible to do with fixed-size raster graphics. In addition,
WPF leverages Direct3D for vector-based rendering and makes use of the graphics processing unit on
any video card that implements DirectX in hardware.
With WPF, graphics elements can easily be integrated into any part of your user interface. For
example, WPF provides 2D shape elements that can be involved in the user interface (UI) tree like other
elements can. You are free to mix these shapes with any other kind of element, such as a button. The
WPF 3D model is based on Direct3D technology and allows you to create a custom 3D shape library that