Introduction to WPF

Introduction

In this article we will just go through a introduction to WPF in a nutshell..

To start with WPF, the following points need to be understood by the programmer.

1. WPF

WPF stands for Windows Presentation Foundation. It's a re-invention of a UI for Desktop applications using WPF. Apart from dropping controls on "Windows Forms" just as developers have been doing for years, WPF provides an extra rapid boost to the application development including Rich User Interface, Animation and much more.

WPF also allows programmers to develop web pages which can be run within a web browser. In a nutshell the following things can be done using WPF:

  • Draw normal controls and graphics.
  • Can easily load/play audio and video files.
  • Can provide smooth graphical effects such as drop shadows and color gradients.
  • Can use shared styles which can be used across the same controls to provide the same theme, skin and design.
  • Transforming objects including shapes, controls and video.
  • Can create and animate 3D graphics.
  • Can easily draw vector graphics that scale without jagged aliasing.
Here are many articles and tutorials on WPF section.

2. XAML

XAML stands for "eXtensible Application Markup Language". Applications load XAML code to load the UI. XAML has its own objects to represent windows, controls, resources, styles and other objects.

XAML is also considered to be a Declarative language. 

You can learn XAML here.

What is Declarative Language?

Declarative programming is a paradigm that express a logic of computation without describing its control flow. So XAML is a declarative language since it describes what should appear on a webpage and does not specify the possible interactions with it.

e.g.

<StackPanel>

<Image Margin="5" Height="50" Source="Frog.jpg"/>

<Label Margin="5" Content="Frog"/>

</StackPanel>

Image and label are being placed under a StackPanel Control.

3. Object Trees

It has two components:

  • Logical Tree: It is defined as a content relationship among the objects in the User Interface. It also includes controls contained within other controls as in Figure 1 and the simple content such as a string contained in a Label.
  • Visual Tree: It represents the structure of visual objects including the components that define them. For example, a scrollbar includes a draggable thumb, two arrow buttons at the ends, and two clickable areas between the thumb and the arrows. Each of those pieces is a separate object that is wrapped inside a scrollbar, and each of the pieces is part of the Visual Tree.

4. Silverlight

  • Silverlight (formerly known as WPF/e, where the e stands for "everywhere") is a comprehensive version of WPF to build browser/web applications with a rich UI.

5. Content Controls: Content Controls are primarily intended to hold content that the user should see. They display something that the user should view but generally won't modify. A few controls are in this category:

  • Border
  • BulletDecorator
  • Document Viewer
  • GroupBox
  • Image, Label, ListView, MediaElement, Popup, Progressbar etc.

6. Layout Controls: They are primarily intended to contain and arrange other controls. They position the controls they contain in various ways to make easier to design various kinds of user interfaces. The following are the controls:

  • Canvas
  • DockPanel
  • Expander, Grid, StackPanel, StatusBar, TabControl etc.

Summary

In this article, we discussed "What is WPF" and its basic structure. It will help us to get a better understanding while we go with the next articles to start with each component individually.

Thanks for reading. Please provide your valuable inputs and suggestion.