Sessions: Microsoft Silverlight 2: Control Model

silverlight 2 control model
user controls
custom controls

User Controls
->bundle visual and logic tight coupling between code and xaml
-application decomposition

custom controls
-modularize control, separation  between code and xaml

styling and skinning controls
skinning->completely replace the look of your control
template binding

silverlight2 control model
0user control
custom control

how do you create a new custom control

public class weathercontrol: control


need to give a default look to a control , a generic resource xaml page. resource dictionary

custom control structure
-control subclass: look-less by default
-default style

introducing the parts and states model
how to structure your control
defined separation between logic & visuals
explicit control contract


-named elements in template
code manipulates element in some way
not all control contracts have parts

-visual look of control in a particular state
-visual transition
states group
-set of mutually exclusive states
-different state groups are orthogonal

demo: checkbox skin
-add visual state groups
-define two visual state groups

using states
-visualstategroup class

visualState class
-contains storyboard that represents visual look

using transitions
-vuisualtransition class
-contains duration for automatic transition animations
automatic animation transition

selecting the visualtransition
type of transitions
from/to <visualtransition to=""…
visual state manager looks for the most specific transition, if not found it goes back to default state.

Demo: weather control with animation!

creating the control class logic
-templatepart and tempaltevisualstate
-not used by runtime , leveraged by tools
publicstatic visualstatemanager.gotostate()
manages visual state change logic and transitions
public override void onapplytempalte()
-called when new template has been applied

more interesting transitions
-can provide explicit transitions animations visual transition.storyboard

developer and designers
demo: skinning in blend

silverlight and WPF control model
the same
-usercontrol, customcontrol
-style, controltemplate

silverlights’2 style
-write-once style property->cant change during run time
-no basedon styles support
-no application-level themes support

visualstatemanager in wpf?
-enables easy port of controls and skins
future: next release of wpf

Demo visualstatemanager in wpf

-attach vsm skin to existing wpf control
-wpftoolkit comes with

Triggers in silverlight

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s