Tutorials » WPF tutorials »

Some Important Classes and Namespaces

This article provides information about some important classes and namespaces of WPF.

Some Important WPF Classes and Namespaces:-

In the previous chapters you got a clear understanding of WPF, XAML and WPF Designer. You have also developed a simple application. You may notice that the application development in WPF has the same process as that of Window Application development. But behind the sense it has a lot of differences. Here we are actually designing the interface by writing XAL like code known as XAML. We will learn about XAML and how to work with detail in the next chapters onwards.

Before working with WPF you need to know some common classes and interfaces and their uses. So in this chapter you will get a clear understanding of different classes and interfaces and there uses.

Before knowing the classes and namespaces you need to know, what are the base assemblies that provide different classes ad interfaces for a WPF application. WPF has three base assemblies. These are as below,

1.WindowsBase.dll:- This assembly defines the core types that constitute the infrastructure WPF API.

2.PresentationCore.dll:- As the name specifies this assembly specifies different types for WPF GUI layer.

3.PresentationFoundation.dll:- It defines the WPF control types, animation, multimedia and data binding support. It also specifies some other functionality.

The above three namespaces are managed namespaces. Besides these three namespaces WPF also uses an unmanaged library, i.e. milcore.dll. This library is responsible to work with DirectX layer. It acts as a bridge between the managed WPF assemblies and the DirectX layer.

Some WPF Classes:-

All these three assemblies provides a number of new namespaces and hundreds of new .NET types(classes, interfaces, structures, enumerations and delegates) to work with WPF. For detailed list you can refer .NET 3.5 SDK documentation. Now have a look at the following class diagram and the class’s functionality.

WPF Class Diagram

DispatcherObject:- It is an abstract base class for classes that are bound to one thread. Classes that are derived from DispatcherObject have an associated Dispatcher object that can be used to switch the threads.

Application:- In every WPF application, one instance of Application class is created. This class implements a singleton pattern for access to the window of application, resources and properties. See the below image.
Application Class

DependencyObject: - It is the base class for all the classes that supports Dependency property.

Visual: - It is the base class for all the visual elements of WPF. This class includes features for transformation.

UIElement: - It is the abstract base class for all WPF elements that need basic presentation feature. This class provides evens such as mouse move, drag and drop, click, etc.

FrameworkElement: - It is derived from base class UIElements and implements the default behaviour of the methods defined by the base class.

Shape: - Shape is the base class for all the shape elements such as, line, rectangle, ellipse, polygon.

Control: - It is derived from FrameworkElement and is the base class for all the user-interactive elements.

Panel: - As the name suggest it is the abstract base class for all the panels and is derived from FrameworkElement. Panel class has a Children property for all the UI-Element that is inside a panel and defines methods for arranging the child controls. Panel defines different classes to define the behaviour of child controls such as, WrapPanel, StackPanel, Grid and Canvas.

ContentControl: - It is the base class for all the controls that have a single content such as, Buttons, Labels, CheckBox, RadioButton, etc.

You can also find the class hierarchy of your application using Object Browser in VS 2008. To view Object Browser go to view menu and select Object Browser. Object Browser also contains all the namespaces and its classes. See the below image for WPF class hierarchy. It is the class hierarchy of a simple WPF application that we have created earlier. Using Object Browser you can find all the methods, properties and events of a particular class by selecting that class.

WPF Class Heirarchy

Some WPF Namespaces:-

Now have a look at some important namespaces of the WPF.

System. Windows:- It is the core namespace of WPF. You will find all the base classes such as, Application, DependencyObject , DependencyProperty and FrameworkElement here.

System. Windows. Controls:- This namespaces contains all the controls of WPF. You will also find classes to work with complex controls such as PopUp, ScrollBar, StatusBar, TabPanel, etc. as well as all the basic controls.

System. Windows. Data:- This namespace is used by WPF for Data Binding.

System. Windows. Input:- This namespace provides several classes for command handling, keyboard input, etc.

System. Windows. Markup:- This namespace helper classes for XAML markup code.

System. Windows. Media:- This namespace is responsible to work with images, audio, and multimedia.

System. Windows. Shapes:- This namespace provides core classes for UI such as Line, Rectangle, Ellipse, etc.

System. Windows. Threading:- This namespace provides classes to work with multiple threads.

System. Windows. Navigation:- This namespace provides classes for navigation between WPF pages particularly when working with Web Applications.

What's Next?

This chapter does not provide detailed information of all the classes and namespaces. you have to refer the MSDN documentation at the provided link. In the next chapter you will get an introduction to XAML. There you will learn the procedure to write XAML codes. then we will proceed to the uses of different controls of WPF.

Next Chapter: Introduction to XAML
Previous Chapter: Your First WPF Application
More Chapters: WPF Tutorials
More Tutorials: Tutorial Index

Top Contributors
TodayLast 7 Daysmore...

Awards & Gifts

Online Members

Rakesh Patel
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India