Académique Documents
Professionnel Documents
Culture Documents
Controls
UserControl
Control
FrameworkElement
User Controls
To create a user control:
%efine a UserControl ele ent *y using +AML %efine a 'lass that inherits fro UserControl Use styles and triggers if re,uired
-our 'ontrol 'onsists only of e.isting 'o ponents -ou do not need to support 'o ple. 'usto i/ation
Custo
Controls
Creating a Custo 0
ple enting Co
<UserControl x:Class="MyNamespace.NumericUpDown" ...> <Gri ...> <Text!lock ..."> <#epeat!utton ...>Up<"#epeat!utton> namespace $%Namespace & pu'lic class NumericUpDown : UserControl & ...
pu'lic static rea onl% DependencyProperty (alue)ropert% = Depen enc%)ropert%.Register*"(alue"+ ...,pu'lic ecimal (alue & .et & return * ecimal,GetValue*(alue)ropert%,- / set & SetValue*(alue)ropert%+ 0alue,- / / pu'lic static rea onl% RoutedE ent (alueC1an.e E0ent = E0ent$ana.er.RegisterRoutedE ent*"(alueC1an.e "+ ...,-
Creating a Custo
Control
namespace $%Namespace & pu'lic class NumericUpDown : Control &.../ ... <2pplication xmlns:local="clr3namespace:MyNamespace" ...> <2pplication.#esources> ... <ControlTemplate Tar.etT%pe="&x:T%pe local:NumericUpDown/"> <Gri > ...
0 ple enting Co
ands
'ontrols to de'ouple
-ou i ple ent 'o ands in 'usto the event handling for the 'ontrol
<#epeat!utton Comman ="&x:4tatic local$NumericUpDown.!ncreaseCommand/" ...>Up<"#epeat!utton> <#epeat!utton Comman ="&x:4tatic local$NumericUpDown.DecreaseCommand/" ...>Down<"#epeat!utton>
pu'lic class NumericUpDown : Control & pu'lic static RoutedCommand !ncreaseCommandpu'lic static RoutedCommand"DecreaseCommand# ... %efined in the te plate of a 4t%le ele ent
<#esourceDictionar% ...> <4t%le Tar.etT%pe="&x:T%pe local:NumericUpDown/"> <ControlTemplate Tar.etT%pe="&x:T%pe .../"> ... 5assem'l%: T1eme6n7o* #esourceDictionar%8ocation.None+ #esourceDictionar%8ocation.4ource2ssem'l%,9 %efined in generi'2.a l
Notes 1age Over$flow (lide2 %o Not 1rint (lide2 (ee Notes pane2
Control
User na e 1assword
Estimated time:
La* &eview
9ow do you i
'ontrol? 'ontrol?