WPF Overview
白石
开发主管
微软
Agenda
• What is WPF
• Why WPF
• WPF Architecture
• What’s new in WPF
• How to choose
What is WPF
“Windows Presentation Foundation” is a new
unified presentation subsystem for Windows. It
consists of a display engine and a managed-
code framework. WPF unifies how Windows
creates, displays, and manipulates documents,
media, 2D, 3D graphics, and user interface,
which enables developers and designers to
create visually-stunning, differentiated user
experiences that improve customer connection.
Why WPF
– Web Windows
– 1995 - HTML – 1995 – Win32
• Sacrificed UX for New level of functionality
portability connectivity
portability, for installed applications
and simplicity Many libraries on top
including MFC, ATL, VB
– 1997 – DHTML
– 1996 – DirectX
Di tX
• Interactivity for the web; Gaming platform for
not heavily used until Windows
recently
– 2002 – Windows Forms
– 2005 – Increasing Developer productivity
Interactivity for Win32
• The “rediscovery” 2006
of and Beyond
DHTML Risingg demand for richness
Customer want better experience
Why WPF
• Integrate the user experience of Web application
andd window
i d application
li ti
• Integration
– 2D Graphics (GDI or GDI+)
– User Interface (WinForm or Common Controls)
– M di (Di
Media (DirectShow)
tSh )
– 3D (Direct3D, OpenGL)
• Utilize
Utili ththe power off GPU
– If CPU is busy doing graphics, it is not doing some
other important task
• Declarative Programming (XAML)
• Document lifecycle (XPS)
WPF is a combine system
• DirectX (3D and hardware acceleration)
• Windows Forms (developer productivity)
• Adobe Flash (powerful animation support)
• HTML (declarative markup and easy
dep oy e t)
deployment)
WPF Architecture
What’s
What s new in WPF
• XAML
• Style & Template
• Triggers
• Flexible Content Model
• Adaptable UI Layout
• Rich Application Text
• Advanced Graphics
• Unified Windows/Web Application
XAML
• eXtensible Application
pp Markup
p Language
g g
• XAML is just convenient shorthand for writing UI
code
• XAML isn’t a wholesale replacement for .Net
language
g g
<Grid Background="silver" ShowGridLines
ShowGridLines="true">
="true">
<[Link]>
[Link]>
<ColumnDefinition Width=
Width="Auto"/>
Auto />
<ColumnDefinition Width="*"/>
</[Link]
</[Link]>
>
<Button Foreground="Red"
Foreground= Red [Link]
Grid Column="0"
[Link]=
Column="0"
= 0 >
Helloworld!!
Helloworld
</Button>
<CheckBox [Link]
Grid Column="1"
Column="1"
1 Content
Content="Column2"/>
Column2 />
</Grid>
Style & Template
• Style
– Removed explicit
p relationship
p between
control’s code(behavior) and UI
– Code only care the behavior
behavior, while Style is in
charge of the UI
• C
ControlTemplate
t lT l t
• DataTemplate
p
Triggers
• Trigger / MultiTrigger
• DataTrigger / MultiDataTrigger
• EventTrigger
<Style TargetType="{x:Type
TargetType="{x:Type CheckBox
CheckBox}">
}">
<[Link]>
[Link]>
<Trigger Property=
Property="IsMouseOver
Property="IsMouseOver
IsMouseOver"" Value=
Value="true">
true >
<Setter Property="
Property="IsChecked
IsChecked"" Value="true"/>
<Setter Property="Foreground" Value="Red"/>
</Trigger>
/T i
</[Link]
</ [Link]>>
</Style>
Flexible Content Model
• Remove the restrict on the content controls
– Button
– MenuItem
– Label
– …
• E
Extend
t d ththe power off expressing
i application
li ti
content
Adaptable UI Layout
• Size-to-Content
• Measure/Arrange
• Panels
– StackPanel
– DockPanel
– Grid / UniformGrid
–…
Rich Application Text
• Let’s
Let s windows application has the same text
capabilities as web application
• Make it easier to integrate richly formatted text
into application
• Make
M k it easieri tto b
build
ild a d
documentt application
li ti
(RichTextBox, TextBlock, FlowDocumentReader,
D
DocumentViewer
tVi etc)
t )
• Vector text (anti-aliasing)
Advanced Graphics
• Enhanced Drawing Capabilities
• Resolution Independence
• Built-In Animation, Video, 3D
• RenderCapability (Tier)
– 0: No graphics hardware acceleration
– 1: Partial graphics hardware acceleration
– 2:
2 MMostt graphics
hi ffeatures
t use graphics
hi
hardware acceleration
Unified Windows/Web Application
How to choose
• WPF vs [Link]
– WPF needd .Net
N t Framework3.0
F k3 0 runtime
ti
– [Link] can be browser everywhere
• WPF vs WinForm/Common controls
– WinForm/Common control has many mature control
libraries and trained developers
p
– WPF gives you the ability to create fantastic applications.
• WPF vs DirectX
– WPF does its rendering via DirectX
– DirectX is the best choice for Games
– WPF sacrifice
ifi a little
littl performance
f for
f integration
i t ti animation,
i ti
media, 2D, 3D to provide a unified programming model
获取更多
获取更多MSDN资源
资源
• MSDN中文网站
[Link]
• MSDN中文网络广播
http://
// [Link]/china/msdn/webcast
/ / /
• MSDN中文网络广播课程预告邮件
[Link]
• MSDN免费中文速递邮件 (MSDN Flash)
[Link]
• MSDN开发中心
[Link]
• MSDN图书中心
[Link]
Question & Answer
如需提出问题,请在此区域输入文字,并单击
“问题和解答”右上方的“提问”按钮即可。
您也可以选择在微软中文技术论坛上寻求帮助,MSDN中文网络
广播的讲师们会定期在论坛上为大家解答与课程相关的技术问题。
[Link]
[Link] microsoft com/china
问题1
• WPF是什么的缩写
– Windows Play Foundation
– Windows Presentation Foundation
– World Population Foundation
– WebSphere
W bS h P titi F
Partition Facility
ilit
问题2
• 以下那种概念不属于WPF
– XAML
– Flexible Content Model
– Adaptable UI Layout
– Work
W k Flow
Fl
问题3
• 在本次Talk中,我们没有把WPF与以下那
种技术进行比较
– DirectX
– Winform
– WTL
– [Link]
DEMO
Demo内容
点击添加MSN机器人小新
为您收听下载MSDN中文网络广播课程加油助力!
收听本次课程需具备的条件
Level 200