WPF Examples


WPF Projects

WPF Project

Introduction Of WPF

WPF Stands for (Windows Presentation Foundation) Microsoft introduced WPF(Windows Presentation Foundation) API (Application Programming Interface) in .NET3.0 framework for the first time. WPF merged all the related And unrelated APIs into a single unified object model.

So if you want to use 2D and 3D graphics or multimedia for your application you do not use to need use different APIs. WPF provides all the functionalities you need to develop richer GUI applications .Using WPF You can develop GUI for both windows application and web application.

WPF Tutorials and Interview Question
Birth Of WPF

Microsoft has developed numerous graphical interface toolkits like C++ Win32 API, VB6, MFC, etc. to build desktop applications. These technologies are capable of designing a good GUI interface for the Windows Applications. But these lacks in some additional and advanced features, such as, 2D & 3D Rendering support, Multimedia Support, Animation Support, etc. which are essential now a days.

So Microsoft has introduced WPF(Windows Presentation Foundation) API in .NET3.0 framework for the first time. It is released in the year 2007. .NET 3.0 is officially shipped for the first time with Windows Vista OS. But Windows XP and 2003 versions can also use .NET 3.0. Visual Studio 2005 is the first gateway to program .NET 3.0 applications. So to develop WPF application you need Visual Studio 2005 or later.

New Features In WPF

The followinig Figure gives you an overview of the main new features of WPF

Architecture Of WPF

In This Architecture These Three assemblies can be categorized as

  • Managed Layer
  • UnManaged Layer
  • Core API
  • Managed Layer-

    Managed layer of Windows Presentation Foundation is built using a number of assemblies. These assemblies build up the WPF framework, communicates with lower level unmanaged API to render its content. The few assemblies that comprise the WPF framework are

    1. PresentationFramework.dll- Creates the High level elements like layout panels, controls, windows, styles etc.
    2. PresentationCore.dll - It holds base types such as UIElement, Visual from which all shapes and controls are Derived in PresentationFramework.dll.
    3. WindowsBase.dll- They hold even more basic elements which are capable to be used outside the WPF environment like Dispatcher object, Dependency Objects. I will discuss each of them later.
  • Unmanaged Layer (milcore.dll)-The unmanaged layer of Windows Presentation Foundation is called milcore or Media Integration Library Core. It basically translates theWindows Presentation Foundation higher level objects like layout panels, buttons, animation etc into textures that Direct3D expects. It is the main rendering engine of WPF.
  • WindowsCodecs.dll- This is Diffrent low level API which is used for imaging support in WPF applications. WindowsCodecs.dll comprises of a number of codecs which encodes / decodes images into vector graphics that would be rendered into WPF screen.
  • Direct3D - It is the low level API in which the graphics of Windows Presentation Foundation is rendered.
  • User32 - It is the primary core api which every program uses. It actually manages memory and process separation.
  • GDI & Device Drivers - GDI and Device Drivers are specific to the operating system which is also used from the application to access low level APIs.
  • Class Hierarchy Of WPF

    In Above Figure all Classes of Wpf (Windows Prensentaion Foundation) We Discuused in Detail

    Difference Between WPF And SilverLight
    WPF SilverLight
    WPF is based off of the desktop CLR which is the full version of the CLR Silverlight is based on a much smaller and more compact CLR which provides a great experience but does not have the full breadth of CLR features. It also has a much smaller version of the BCL
    WPF you can create Windows App, Navigation app and XBAP (IE based) application Silverlight you can create only XAP (Browser based application.).
    WPF supports 3 types of routed events (direct, bubbling, and tunneling) Silverlight supports direct and bubbling only.
    WPF support MultiBinding Silveright doesnot support MultiBinding
    WPF Support Both Silverlight supports the XmlDataProvider but not the ObjectDataProvider
    Advantage of WPF
    1. Broad Integration- Prior to WPF, it was very difficult to use 3D, Video, Speech, and rich document viewing in addition to normal 2D Graphics and controls would have to learn several independent technologies. WPF covers all these with consisting programming model as well as tight integration when each type of media gets composited and rendered.
    2. Resolution Independence- WPF applications are device independent i.e., smart client applications. Like normal applications it won’t get decrease the size as the resolution gets increase. This is possible because WPF emphasis on vector graphics.
    3. Hardware Acceleration- WPF is built on top of Direct 3D, content in a WPF application whether 2D or 3D, Graphics or text is converted to 3D triangles, textures and other Direct 3D objects and then rendered by hardware. WPF applications can get the benefit of hardware acceleration for smoother graphics and all round better performance.
    4. Declerative Programming- WPF takes the declarative programming to the next level with the introduction of Extensible Application Markup Language(XAML), pronounced as “Zammel”.
    5. XAML is like HTML in web used for creating the interface, resulting graphical designers are empowered to contribute directly to the look and feel of applications.
    6. Rich Composition and Customization- WPF controls are extremely compostable.Eg: we can create combo box with animated buttons.