8/10/2019 Windows Presentation Foudation - WPF Day 2
1/21
By
Apex TG India Pvt Ltd
WPF, Windows Presentation FoundationA platform for building rich user experiences on Windows
http://www.apextgi.in/http://www.apextgi.in/8/10/2019 Windows Presentation Foudation - WPF Day 2
2/21
Presentation Scope
What's covered:
XMALBasic Ee!ents o" WP#Architect$reProperty Syste! % &ependency Property
o$ted EventsBindin( Syste!Styin( % Te!patin(
What)s *ot covered:+ontros Li,rary
Graphics % M$ti Media&oc$!ents
8/10/2019 Windows Presentation Foudation - WPF Day 2
3/21
8/10/2019 Windows Presentation Foudation - WPF Day 2
4/21
Tech Anaysis
WinForms
PDF WinForms +
GDI
WindowsMediaPlayer
Direct3D WPF
Forms,Controls
X X X
Complex text X X
Images X X
ideo ! "#dio X X
$D Grap%ics X X
3D Grap%ics X X
e"erence: http:%%windowsclient.net/wpf/white-papers/when-to-adopt-wpf.aspx
8/10/2019 Windows Presentation Foudation - WPF Day 2
5/21
The Appication +ass
Additiona appication.scoped services5 inc$din( +reatin( and !ana(in( co!!on appication in"rastr$ct$re0
Trac4in( and interactin( /ith appication i"eti!e0 Start$p Activated &eactivated Sh$tdo/nMode 28nLastWindo/+ose58nMainWindo/+ose5 8nExpicitSh$tdo/n3
SessionEndin( 2Lo((in( o""5Sh$ttin( do/n5estartin(5i,ernatin(3 Exit
etrievin( and processin( co!!and.ine para!eters0 Example Sharin( appication.scope properties and reso$rces0
Exa!pes in +ode &etectin( and respondin( to $nhanded exceptions0 Exa!pe in +ode
8/10/2019 Windows Presentation Foudation - WPF Day 2
6/21
The Appication +ass
et$rnin( exit codes0
Exa!pe in +ode Mana(in( /indo/s in standaone appications Trac4in( and !ana(in( navi(ation
using System.Windows.Navigation!. "#yperlin$ %ontrol
?=ri8"Pa(eTo*avi(ateTo0xa!?@
*avi(ate to Another Pa(e
8/10/2019 Windows Presentation Foudation - WPF Day 2
7/21
The Appication +ass
(.)rogrammatic Navigation with a )ac$ *+,
%% +reate a pac4 =I =ri $ri > new=ri2?AnotherPa(e0xa!?5 =riCind0eative3
%% Get the navi(ation service that /as $sed to
%% navi(ate to this pa(e5 and navi(ate to
%% AnotherPa(e0xa!
this0*avi(ationService0*avi(ate2$ri3
%onfiguring the #ost Windows itle Width and
#eight
0ragment Navigation
Navigation to a content fragment
PageURI1ElementName
8/10/2019 Windows Presentation Foudation - WPF Day 2
8/21
Navigation 2ifetime
Navigating0 8cc$rs /hen a ne/ navi(ation is reD$ested0 +an ,e$sed to cance the navi(ation0
Navigation)rogress0 8cc$rs periodicay d$rin( a do/noad toprovide navi(ation pro(ress in"or!ation0
Navigated0 8cc$rs /hen the pa(e has ,een ocated anddo/noaded0
NavigationStopped0 8cc$rs /hen the navi(ation is stopped 2,ycain( StopLoadin(35 or /hen a ne/ navi(ation is reD$ested /hie a
c$rrent navi(ation is in pro(ress0 Navigation0ailed0 8cc$rs /hen an error is raised /hie navi(atin(
to the reD$ested content0 2oad%ompleted0 8cc$rs /hen content that /as navi(ated to is
oaded and parsed5 and has ,e($n renderin(0 0ragmentNavigation8cc$rs /hen navi(ation to a content
"ra(!ent ,e(ins5 /hich happens: I!!ediatey5 i" the desired "ra(!ent is in the c$rrent content0 A"ter the so$rce content has ,een oaded5 i" the desired "ra(!ent is in
di""erent content0
8/10/2019 Windows Presentation Foudation - WPF Day 2
9/21
Navigation 2ifetime
8/10/2019 Windows Presentation Foudation - WPF Day 2
10/21
Navigation 2ifetime
3ournal /journal entry(3ournalEntry class)
The ,ac4 stac45 the "or/ard stac4
90 &ecarative !echanis!s provided ,y WP#
8/10/2019 Windows Presentation Foudation - WPF Day 2
11/21
Navigation 2ifetime
Structured Navigation 4verviewStructured Navigation with )age0unction
8ther Types o" Str$ct$red *avi(ation NavigationWindow %lass
,ro/ser.stye navi(ation into yo$r standaone appications
*avi(ation osts
%onfiguring the Application 5efinition for 6S7uildIn MSB$id proect
8/10/2019 Windows Presentation Foudation - WPF Day 2
12/21
WP# Architect$re
8/10/2019 Windows Presentation Foudation - WPF Day 2
13/21
WP# Architect$re
6ore declarative 9property centric9 model of programming
System.hreading.5ispatcher4b:ect Support for concurrency and threading. !essa(in( syste! i!pe!ented ,y the dispatcher0 +reate a +L o,ect that has STA ,ehavior0
hread affinity;
A co!ponent $ses the identity o" the exec$tin( thread to store so!e type o"state0 8LE 60K5 the cip,oard5 and Internet Exporer a reD$ire sin(e thread a""inity
2STA3 exec$tion0
he dispatcher; Basic !essa(e dispatchin( syste!5 /ith !$tipe prioritied D$e$es
Exa!pes o" !essa(es inc$de: a/ inp$t noti"ications 2!o$se !oved3 #ra!e/or4 "$nctions 2ayo$t3 =ser co!!ands 2exec$te this !ethod30
8/10/2019 Windows Presentation Foudation - WPF Day 2
14/21
WP# Architect$re
System.Windows.5ependency4b:ect
5ependency )roperties; To co!p$te the va$e o" a property ,ased on the va$e
o" other inp$ts Syste! properties s$ch as the!es and $ser pre"erence F$st.in.ti!e property deter!ination !echanis!s s$ch as data
,indin( and ani!ations%story,oards M$tipe.$se te!pates s$ch as reso$rces and styes 1a$es 4no/n thro$(h parent.chid reationships /ith other
ee!ents in the ee!ent tree
Also 0or; Se".contained vaidation
&e"a$t va$es +a,ac4s that !onitor chan(es to other propertiesA syste! that can coerce property va$es ,ased on potentiay
r$nti!e in"or!ation0
8/10/2019 Windows Presentation Foudation - WPF Day 2
15/21
WP# Architect$re
System.Windows.6edia.'isual
B$idin( a tree o" vis$a o,ects &ra/in( instr$ctions and !etadata a,o$t ho/ to render
those instr$ctions
2cippin(5 trans"or!ation5 etc030
Point o" connection ,et/een these t/o s$,syste!s5 the!ana(ed API and the $n!ana(ed !icore0
8/10/2019 Windows Presentation Foudation - WPF Day 2
16/21
WP# Architect$re
+o!position:
In =ser76 and G&I: 2I!!ediate !ode cippin( syste!3
a cippin( ,o$nds o$tside o" /hich the co!ponent isn)t ao/edto to$ch the pixes5 and then the co!ponent is as4ed to paintpixes in that ,ox0
Good "or !e!ory constrained environ!ent0
In WP#: ?Painter's a(orith!? paintin( !ode0
To render "ro! the ,ac4 to the "ront o" the dispay0
Each co!ponent to paint over the previo$s co!ponent's dispay0
+o!pex5 partiay transparent shapes0 Better "or ne/ type o" (raphics o,ect0
8/10/2019 Windows Presentation Foudation - WPF Day 2
17/21
WP# Architect$re
System.Windows.*,Element
%ore subsystems including 2ayout ,nput and Events.
2ayout;
!. A fixed set of layout models e. +ule; Si>e to content.
Arrange phase; o allows a parent to position and determine the final si>e of each child.
,nput;
4n a $ernel mode device driver. ?ets routed to the correct process and thread by involving the Windows $ernel and *ser(&. +outed to W)0. W)0 raw input message and sent to the dispatcher. +aw input events to be converted to multiple actual events.
8/10/2019 Windows Presentation Foudation - WPF Day 2
18/21
WP# Architect$re
+outing through the element tree. Events are said to 9bubble9 if they traverse from a target up
the tree to the root. Events are said to 9tunnel9 if that start at the root and
traverse down to a target.
,n the dispatcher for your application you would call
ranslateAccelerator which would sniff the inputmessages in *ser(& and determine if any matched aregistered accelerator.
%ommand7indings.
o define functionality in terms of a command end point @something that implements ,%ommand.
Enable an element to define a mapping between an inputgesture
8/10/2019 Windows Presentation Foudation - WPF Day 2
19/21
WP# Architect$re
System.Windows.0ramewor$Element A set of policies and customi>ations on the subsystems introduced in lower
layers of W)0. A set of new subsystems
)olicies; Application layout 5irect access to animation through the 7eginStoryboard method he data binding subsystem; one or more properties from a given element
to be bound to a piece of data Styling Subsystem; 7ind a set of properties from a shared definition to one
or more instances of an element.
System.Windows.%ontrols.%ontrol emplating allows a control to describe itCs rendering in a parameteri>ed
declarative manner.
he implementation of a control provides a data model and interactionmodel
his split between the data model
8/10/2019 Windows Presentation Foudation - WPF Day 2
20/21
W)0 property system
A set o" services that can ,e $sed to extend the "$nctionaity o" a co!!onan($a(e r$nti!e 2+L3 property0
5ependency property; A property that is ,ac4ed ,y the WP# property syste!0 What 0orD 90 A /ay to co!p$te the va$e o" a property ,ased on the va$e o" other
inp$ts Syste! properties s$ch as the!es and $ser pre"erence
F$st.in.ti!e property deter!ination !echanis!s s$ch as data ,indin( andani!ations%story,oards M$tipe.$se te!pates s$ch as reso$rces and styes 1a$es 4no/n thro$(h parent.chid reationships /ith other ee!ents in the
ee!ent tree0
60 To provide se".contained vaidation5 de"a$t va$es5 ca,ac4s that!onitor chan(es to other properties
70 A syste! that can coerce property va$es ,ased on potentiay r$nti!e
in"or!ation0 0 &erived casses can aso chan(e so!e speci"ic characteristics o" an
existin( property ,y overridin( dependency property !etadata5 rather thanoverridin( the act$a i!pe!entation o" existin( properties or creatin( ne/properties0
8/10/2019 Windows Presentation Foudation - WPF Day 2
21/21
Top Related