Summary

  • Windows Presentation Foundation (WPF) is a system intended to combine the functionality of Windows Forms with greater flexibility in interface design.

  • In WPF, the presentation of the application is kept in a separate file, written in XAML, which is a dialect of XML.

  • When you start a new WPF project, Visual Studio opens both the Design window and the XAML window. Changes made in one window are immediately reflected in the other.

  • The XAML file uses a Window element as its root element.

  • Each WPF application uses a distinct namespace, defined by the Microsoft XAML schema, and you can add your own objects to that namespace.

  • XAML contains several elements for positioning other elements within the application, including the Grid and Stackpanel elements.

  • You can set the properties of XAML elements in the Properties window, or by editing the XAML directly.

  • Event handlers for WPF elements are kept in a code file, written in C# or another .NET language.

  • Resources allow you to define properties for use by any appropriate element in the application.

  • Resources require you to define a key in the current namespace so that you can refer to them later in the application.

  • A Style element, which can be defined on an element or as a resource, can contain a number of Setter elements that define specific properties of the target element.

  • Routed events in WPF can be associated with triggers, which can change the properties of elements in response to events. Triggers can be defined on individual elements, or as resources.

  • Animation elements are contained within Storyboard elements. There are different animation elements depending on the type of the value that the animation is changing.

  • A trigger can contain a storyboard action, which can contain a storyboard element, but a trigger cannot contain a storyboard by itself.

  • Many triggers can be declared completely declaratively, without needing to write any C# code.

  • The DataContext property allows an element to access a data source.

Your skills have come a long way from where they were at the beginning of the book, through the various pieces of the C# language, and now into Windows applications in a couple of different ways. There’s still one major piece of the development puzzle that we’ve left untouched, though: handling data. You saw in the Presidential Browser application in this chapter that you had to handcode the URLs for 20 images into the Resources section of your application; that’s a real pain. It would have been much easier if you could have read the information directly from a repository of some kind. Fortunately, many such repositories are available, from simple XML files to full-fledged SQL databases, and C# can access many of them. We’ll spend the final two chapters of this book looking at how to access data from C#, first with ADO.NET and then with the newer Language Integrated Query (LINQ) methods.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset