HO CHI MINH UNIVERSITY OF INDUSTRY
What's New in WPF Version 4.5?
HO CHI MINH UNIVERSITY OF INDUSTRY
Windows Presentation Foundation
1
Benefits
2
Tools
3
Discussion of WPF applicability
4
HO CHI MINH UNIVERSITY OF INDUSTRY
What is WPF?
WPF is a new API for building Windows applications
The goal of Windows Presentation Foundation (WPF) is to provide these advances
for Windows. Included in version 4.0 of the Microsoft .NET Framework, WPF allows
building interfaces that incorporate documents, media, two- and three-dimensional
graphics, animations, Web-like characteristics, and much more.
HO CHI MINH UNIVERSITY OF INDUSTRY
What Windows Presentation Foundation Provides?
Three most important:
a unified platform for modern user interfaces
the ability for developers and designers to work together,
and a common technology for Windows and Web browser user interfaces.
HO CHI MINH UNIVERSITY OF INDUSTRY
What is WPF good for?
To enable designers and developers to work together
To allow an easy way to customize the look of controls without changing its
behavior
To allow 3D graphics more easily in Windows applications
To allow an easy way to do animations in Windows applications
To enable the creation of applications which scale nicely to high resolution
screens
HO CHI MINH UNIVERSITY OF INDUSTRY
Which of these UI have you worked with?
GDI (20 years), GDI+, WinForms
DirectX (11 years), Direct3D
Quartz, DirectShow (8 years)
– Problems:
• Showing their age
• Each API is different
• Mixing APIs is challenging
HO CHI MINH UNIVERSITY OF INDUSTRY
Next Gen
WPF – replaces GDI
Direct3D – large games, used by WPF
Media Foundation – ultimately will replace DirectShow
MCML –markup language for Media Center Edition applications
XNA – small games
HO CHI MINH UNIVERSITY OF INDUSTRY
WPF
Declarative programming with XAML markup
For Designers and Developers
Rewritten from scratch
– Built on top of Direct3D
– Hardware accelerated
– Vector based
– Resolution independent (1/96 inch)
– Retained graphics
HO CHI MINH UNIVERSITY OF INDUSTRY
Most of WPF is written in
managed code
milcore is the only unmanaged
component of WPF
Overview of WPF Architecture
HO CHI MINH UNIVERSITY OF INDUSTRY
Managed Code:
Code write in .net framework environment is call Managed code, they will be
executed direct from CLR(Common Language Runtime). CLR will manage
memory, security problem, debugging…and other useful features
HO CHI MINH UNIVERSITY OF INDUSTRY
Unmanaged Code
Not in .net framework, that is not controlled by CLR, Unmanaged Code will
bee execute with 2 wrapper class support:
CCW (COM Callable Wrapper)
and
RCW (Runtime Callable Wrapper).
HO CHI MINH UNIVERSITY OF INDUSTRY
CCW (COM Callable Wrapper)
HO CHI MINH UNIVERSITY OF INDUSTRY
RCW (Runtime Callable Wrapper)
HO CHI MINH UNIVERSITY OF INDUSTRY
XAML:
Extensible Application Markup Language
Declarative object instantiation
Not exclusive to WPF
Separates UI and logic
– Common language for Designers and Developers
• Demo: Blend and VS
– Parallel development
– Localization, Branding
– Targeted UI (devices, users, …)
Tool support
Supports C# and VB.NET
HO CHI MINH UNIVERSITY OF INDUSTRY
Benefits
Markup/code-behind model (like ASP.NET)
Excellent layout options and text flow features
Access to powerful graphics hardware
Certain otherwise-impossible effects are made easy (skewing and rotating
textboxes, etc.)
HO CHI MINH UNIVERSITY OF INDUSTRY
Tools
• Cider
• XAML Pad
• 3D tools such as Light wave can generate XAML.
– Electric Rain Zam 3D
– Mobiform Aurora
– Cinema 4D
• Microsoft Expression
– Graphics Designer
– Interactive Designer
HO CHI MINH UNIVERSITY OF INDUSTRY
Comparisons: WPF vs. DirectX and GDI+
HO CHI MINH UNIVERSITY OF INDUSTRY
WPF Build Pipeline
HO CHI MINH UNIVERSITY OF INDUSTRY
Basic topics in WPF
WPF code and XAML
Property & object in XAML: syntax
Layout
Basic control
Basic property
WPF Concepts
HO CHI MINH UNIVERSITY OF INDUSTRY
1. WPF code and XAML: first app
WPF code
– New consoles project (or Windows Apps)
– Reference: PresentationCore, PresentationFramework, and WindowsBase
How to create this window?
HO CHI MINH UNIVERSITY OF INDUSTRY
using System.Windows;
using System.Windows.Controls;
namespace StudyWPFApplication
{ public class Class1
{
[STAThread]//Must insert before Main
public static void Main(string[] aargs){
Window w = new Window();
Button btn = new Button();
btn.Width = btn.Height = 100;
btn.Content = "Click Me!";
w.Content = btn;
w.Title = "Khoa Công Nghệ Thông Tin";
Application A = new Application();
A.Run(w);}
}
}
HO CHI MINH UNIVERSITY OF INDUSTRY
1. WPF code and XAML: first app
From VS template
App is inherited from Application
Window1 is inherited from Window
HO CHI MINH UNIVERSITY OF INDUSTRY
HO CHI MINH UNIVERSITY OF INDUSTRY
1. WPF code and XAML: first app
From VS template
Write 2 example: code and Xaml
HO CHI MINH UNIVERSITY OF INDUSTRY
1. WPF code and XAML: first app
From VS template
Write 2 example: code and Xaml