Sunday, May 15, 2011

Expression blend : control styling tip, Using element binding rather than parts

There is a small trick used extensively in the movies scenario in .toolbox :
http://www.microsoft.com/design/toolbox/school/modules.aspx?lid=2&mid=6

When you are styling a control and there are parts defined in the control that are of types that cannot be made to look the way you want there is a way around it :

  • Hide the original parts by using setting the visibility to collapsed
  • Make a usercontrol / customcontrol of the type you want and add it to the template
  • Bind properties of your usercontrol/customcontrol to properties of the original part (which is collapsed but still present) by element binding. Make sure the binding is twoway and the trigger is default.
This means you can make really crazy looking sliders and other stuff :)