WPF

13

Click here to load reader

description

 

Transcript of WPF

Page 1: WPF

WPF(WINDOWS

PRESENTATION FOUNDATION)

Kadir H. Kapadiya

Jr. S/W Developer

Page 2: WPF

What is WPF?

WPF is the engine that is responsible for creating, displaying, and manipulating user-interfaces, documents, images, movies, and media in Windows Vista.

Physically, WPF is a set of libraries that have all functionality you need to build, run, execute, and manage Windows Vista applications.

WPF combines application UIs, 2D graphics, 3D graphics, documents and multimedia into one single framework. Its vector based rendering engine uses hardware acceleration of modern graphic cards. This makes the UI faster, scalable and resolution independent.

Page 3: WPF

Windows Presentation Foundation (WPF) is a next-generation presentation system for building Windows client applications with visually stunning user experiences.

With WPF, you can create a wide range of both standalone and browser-hosted applications.

WPF is included in the Microsoft .NET Framework, so you can build applications that incorporate other elements of the .NET Framework class library.

Page 4: WPF

Separation of Appearance and Behavior

WPF separates the appearance of an user interface from its behavior. The appearance is generally specified in the Extensible Application Markup Language (XAML), the behavior is implemented in a managed programming language like C# or Visual Basic.

The two parts are tied together by data binding, events and commands. The separation of appearance and behavior brings the following benefits:

1. Appearance and behavior are loosely coupled

2. Designers and developers can work on separate models.

3. Graphical design tools can work on simple XML documents instead of parsing code.

Page 5: WPF

Advantage of WPF:

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.

Resolution Independence: WPF applications are device independent i.e., smart client applications. Like normal applications it don't get decrease the size as the resolution gets increase. This is possible because WPF emphasis on vector graphics.

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.

Declarative Programming: WPF takes the declarative programming to the next level with the introduction of Extensible Application Markup Language(XAML)

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.

Page 6: WPF

WPF Architecture WPF is actually a set of assemblies that build up the entire

framework. These assemblies can be categorized as:

1. Managed Layer

2. Unmanaged Layer

3. Core API

Page 7: WPF

Managed Layer: Managed layer of WPF is built using a number of assemblies. These assemblies build up the WPF framework, communicate with lower level unmanaged API to render its content. 

1. PresentationFramework.dll: Creates the top 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 of being used outside the WPF environment like Dispatcher object, Dependency Objects.

Page 8: WPF

Unmanaged Layer (milcore.dll): The unmanaged layer of WPF is called milcore or Media Integration Library Core. It basically translates the WPF 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 another low level API which is used for imaging support in WPF applications. WindowsCodecs.dll comprises a number of codecs which encode / decode images into vector graphics that would be rendered into WPF screen.

Direct3D: It is the low level API in which the graphics of WPF 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.

Page 9: WPF
Page 10: WPF

<Window x:Class="FirstWindowsApplication.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Name="Window1"

Title="Window1" Height="300" Width="300">

<Grid>

<Grid.RowDefinitions>

<RowDefinition Height="Auto" />

</Grid.RowDefinitions>

<Grid.ColumnDefinitions>

<ColumnDefinition MinWidth="50" />

<ColumnDefinition Width="Auto" />

<ColumnDefinition Width="*" />

</Grid.ColumnDefinitions>

<TextBlock Text="Enter Name :" Grid.Row="0" Grid.Column="0" />

<TextBox x:Name="txtName" Grid.Row="0" Grid.Column="1" MinWidth="50"/>

<Button Content="Click Me" Grid.Row="0" Grid.Column="2" Click="Button_Click"/>

</Grid>

</Window>

Page 11: WPF

private void Button_Click(object sender, RoutedEventArgs e)

{

MessageBox.Show(string.Format("Hi {0}", this.txtName.Text));

}

Page 12: WPF

Difference Between  WPF And 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 With 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.

Silverlight does not support MultiBinding.

Silverlight supports the XmlDataProvider but not the ObjectDataProvider. WPF supports both.

Page 13: WPF

Thank You