Product Details
Programming WPF: Building Windows UI with Windows Presentation Foundation

Programming WPF: Building Windows UI with Windows Presentation Foundation
By Chris Sells, Ian Griffiths

List Price: £38.50
Price: £22.42 & eligible for FREE Super Saver Delivery on orders over £5. Details

Availability: Usually dispatched within 24 hours
Dispatched from and sold by Amazon.co.uk

40 new or used available from £21.66

Average customer review:

Product Description

If you want to build applications that take full advantage of Windows Vista's new user interface capabilities, you need to learn Microsoft's Windows Presentation Foundation (WPF). This new edition, fully updated for the official release of .NET 3.0, is designed to get you up to speed on this technology quickly. By page 2, you'll be writing a simple WPF application. By the end of Chapter 1, you'll have taken a complete tour of WPF and its major elements.WPF is the new presentation framework for Windows Vista that also works with Windows XP. It's a cornucopia of new technologies, which includes a new graphics engine that supports 3-D graphics, animation, and more; an XML-based markup language, called XAML, for declaring the structure of your Windows UI; and a radical new model for controls.This second edition includes new chapters on printing, XPS, 3-D, navigation, text and documents, along with a new appendix that covers Microsoft's new WPF/E platform for delivering richer UI through standard web browsers - much like Adobe Flash. Content from the first edition has been significantly expanded and modified." Programming WPF" includes: scores of C# and XAML examples that show you what it takes to get a WPF application up and running, from a simple "Hello, Avalon" program to a tic-tac-toe game; insightful discussions of the powerful new programming styles that WPF brings to Windows development, especially its new model for controls; a color insert to better illustrate WPF support for 3-D, color, and other graphics effects; a tutorial on XAML, the new HTML-like markup language for declaring Windows UI; and, an explanation and comparison of the features that support interoperability with Windows Forms and other Windows legacy applications. WPF represents the best of the control-based Windows world and the content-based web world. "Programming WPF" helps you bring it all together.


Product Details

  • Amazon Sales Rank: #115992 in Books
  • Published on: 2007-08-28
  • Original language: English
  • Number of items: 1
  • Binding: Paperback
  • 863 pages

Editorial Reviews

From the Publisher
Get up to speed on Windows Presentation Foundation (WPF). By page two, you'll have written your first WPF application, and by the end of Chapter 1, "Hello WPF," you'll have completed a rapid tour of the framework and its major elements, including the XAML markup language, the mapping of XAML to WinFX code; the WPF content model; layout; controls, styles, and templates; graphics, and more.

About the Author
Chris Sells is a Program Manager for the Connected Systems Division at Microsoft. He's written several books, including "Programming WPF", "Windows Forms 2.0 Programming" and "ATL Internals". In his free time, Chris hosts various conferences and makes a pest of himself on Microsoft internal product team discussion lists.

Ian Griffiths is WPF course author and instructor with Pluralsight, and a widely recognized expert on the subject. He also works as an independent consultant and is co-author of "Windows Forms in a Nutshell" and of "Mastering Visual Studio .NET" (both O'Reilly).

Excerpted from Programming Windows Presentation Foundation by Chris Sells, Ian Griffiths. Copyright © 2005. Reprinted by permission. All rights reserved.
Chapter 5 Styles and Control Templates

In a word processing document,a "style "is a set of properties to be applied to ranges of content —e.g.,text,images,etc.For example,the name of the style I ’m using now is called "Normal,Body,b "and for this document in pre-publication,that means a font family of Times,a size of 10,and full justification.Later on in the document, I’ll be using a style called "Code,x,s "that will use a font family of Courier New,a size of 9,and left justification.Styles are applied to content to produce a certain look when the content is rendered.

In WPF,a style is also a set of properties applied to content used for visual rendering. A style can be used to set properties on an existing visual element, such as setting the font weight of a Button control, or it can be used to define the way an object looks, such as showing the name and age from a Person object.In addition to the features in word processing styles, WPF styles have specific features for building applications, including the ability to associate different visual effects based on user events, provide entirely new looks for existing controls, and even designate rendering behavior for non-visual objects. All of these features come without the need to build a custom control (although that ’s still a useful thing to be able to do, as discussed in Chapter 9).

Without Styles

As an example of how styles can make themselves useful in WPF, let ’s take a look at a simple implementation of tic-tac-toe in Example 5-1.

Example 5-1.A simple tic-tac-toe layout

This grid layout arranges a set of nine buttons in a 3 ×3 grid of tic-tac-toe cells,using the margins on the button for the tic-tac-toe crosshatch. A simple implementation of the game logic in the XAML code-behind file looks like Example 5-2.

Example 5-2.A simple tic-tac-toe implementation

//Window1.xaml.cs
...
namespace TicTacToe {
public partial class Window1 :Window {
//Track the current player (X or O)
string currentPlayer;
//Track the list of cells for finding a winner etc.
Button [] cells;;
public Window1(){
InitializeComponent();

//Cache the list of buttons and handle their clicks
this.cells =new Button [] {{this.cell00,this.cell01,...};
foreach(Button cell in this.cells ){
cell.Click +=cell_Click;
}

//Initialize a new game
NewGame();}
//Wrapper around the current player for future expansion,
//e.g.updating status text with the current player
string CurrentPlayer {
get {return this.currentPlayer;}
set {this.currentPlayer =value;}
}

//Use the buttons to track game state
void NewGame(){
foreach(Button cell in this.cells ){
cell.Content =null;
}
CurrentPlayer ="X";
}
void cell_Click(object sender,RoutedEventArgs e){
Button button =(Button)sender;

//Don't let multiple clicks change the player for a cell
if(button.Content !=null ){return;}

//Set button content
button.Content =CurrentPlayer;

//Check for winner or a tie
if(HasWon(this.currentPlayer)){
MessageBox.Show("Winner!","Game Over");
NewGame();
return;
}
else if(TieGame()){
MessageBox.Show("No Winner!","Game Over");
NewGame();
return;
}

//Switch player
if(CurrentPlayer =="X"){
CurrentPlayer ="O";
}
else {
CurrentPlayer ="X";
}
}

//Use this.cells to find a winner or a tie
bool HasWon(string player){...}
bool TieGame(){...}
}
}

Our simple tic-tac-toe logic uses strings to represent the players and uses the buttons themselves to keep track of the game state. As each button is clicked, we set the content to the string indicating the current player and switch players. When the game is over,the content for each button is cleared.The middle of a game looks like Figure 5-1.

Notice in Figure 5-1 how the grid background comes through from the margin. These spacers almost make the grid look like a drawn tic-tac-toe board (although we ’ll do better later).However,if we ’re really looking to simulate a hand-drawn game, we’ve got to do something about the size of the font used on the buttons;it doesn ’t match the thickness of the lines.

One way to fix this problem is by setting the size and weight for each of the Button objects,as in Example 5-3.
Example 5-3.Setting control properties individually

While this will make the X ’s and O ’s look better according to my visual sensibilities today,if I want to change it later, I’ve now committed myself to changing both properties in nine separate places, which is a duplication of effort that offends my coding sensibilities.I ’d much prefer to refactor my decisions about the look of my tic-tac-toe cells into a common place for future maintenance. That ’s where styles come in handy.


Customer Reviews

Yet another mediocre programming book3
WPF is no doubt going to become the standard for Windows programming as it provides a lot more than its predecessor, Windows Forms.

This book describes how to define user interfaces using XAML, an XML-based markup language, but neglects to explain that you don't actually need XAML to write a WPF application.

It takes the reader through the various elements of user interface and describes how they are defined, laid out on the screen and attaching input events to them. However, the examples that it gives are incredibly trivial - so typical of this type of book. If you want to do something a bit more advanced, which WPF is obviously capable of, you're left high and dry. A Tic-Tac-Toe game and a few 3D rendered spheres don't really illustrate the capabilities of WPF.

The book also assumes that you are going to create a WPF application from scratch. If you need to add elements of WPF to an existing Windows Forms application (because Windows Forms is so obviously lacking in any advanced features), you're going to be disappointed by the 3 pages that cover this topic.

In summary, the book shows you the basic WPF elements that you can work with, but the examples are lacklustre.
If you buy this book, I doubt whether it will be the last book on WPF that you buy.

Programming WPF is Perfect!5
Well, not quite but it is the very best book on WPF that I have read (and I have read a few now, Charles P (x2 inc. his 3D book), Chris A and Adam N). I have read much of Chris Sells work over my many years working with software and I truely love his writing style and delivery. His partnership with Ian Griffiths on this is book has worked out wonderfully and the book is a sublime read from beginning to end because of it.

I love working with WPF and this book has been, and continues to be, the perfect guide.

Excellent reference on programming Windows Presentation Foundation!5
Programming Windows Presentation Foundation is very excellent book, ideal for all developers who's interesting building rich and digital applications with new Microsoft technology

for creating visual experiences. This is good book for everything from developers without programming experience on WPF and for experts in this topic. Book contains many

interesting chapters with introduction to all topics, examples and some advanced topics to enable developers to create better WPF application.

If you are interesting working with Windows Presentation Foundation, you must learn this technology from this book! In second edition, writers add to book several interesting

themes, from XPS and printing technology to navigation, and 3D creating. It's amazing how many features have a developers and designer to create layout, realize dreams and

potential. When Microsoft published WPF millions developers around a world get a platform with big potential.

In book You are find:
- Introduction to WPF technology and create first application with XAML language.
- Design modern and high-quality layout for Yours application.
- Connected with Data, binding controls and create rich advanced data applications.
- Graphics and 3D support.
- Printing technology and using XPS.
- Animation and Media in WPF application.

Building rich and friendly applications is very hard, but this is not usual book, this is full professional support for all people who's thinking about create own application on WPF.