Thursday, November 4, 2010

Write your own Xaml Framework

Write your own Xaml Framework - Billy Hollis
www.billyhollis.com

Visual and Logical Trees
Logical tree is the tree you see with elements composed inside other elements.  Visual tree contains everything that effects rendering.  SilverLight has Visualtreehelp, WPF has logicalTree helper too.  He has written a findResouce extension, that can be used to programmatically have code search for resource.

Dependency Properties
Properties elements are usually dependency properties, thes properties depend on factors.  Get/set methods will cll get value/set value in what is called a dependency property store.  Example of these data context, fonts.  These are based on looking up the tree. Have optional callbacks that can be used for validation. Can create them from snippets.

Control template tricks
Can dependency propertis which can be bound to others objestsnproperties.  Can build wrappers for objects to give various objects the same new property

Attached properties
These are type of dependency properties. AttachedPropertytBrowsableForType attribute makes attached property settable in designer. Create in code by using RegisterAttached instead of register. Your setters/Getter properties need to be shared.  When setting up set PrpertyMetaData in default types the same. (error many folks miss) Spellcheck is an attached property for textbox

Behaviors
Give Items behaviors that they normally don’t have.  Mostly useful when it is an extension on that a control, like adding masks to textbox

No comments:

Post a Comment