Saturday, November 3, 2012

Changing Visual State in Custom Control

Call VisualStateManager.GoToState(control, strStateName, useTransitions)
strStateName is mapped to a TemplateVisualStateAttribute of the control class.

Thursday, October 18, 2012

PrintDocument

sample: http://web.archive.org/web/20101128170826/http://silverlightips.net/2010/03/27/multi-page-printing-in-silverlight/
including:
PrintDocument .PrintPage (event) .Print (method)
PrintPageEventArgs .PageVisual (UIElement) .PrintableArea (Size) .HasMorePages

Also usage of Canvas.TopProperty in SetValue

Monday, October 15, 2012

Dependency Properties vs. Attached Properties

Attached Properties use an accessor style that XAML parser can use, i.e. SetPropertyName
As opposed to regular dependency properties that use regular Set/Get accessors.

For attached properties see: http://msdn.microsoft.com/en-us/library/cc265152(v=vs.95).aspx

For regular dependency property requirements see Checklist for Defining a Dependency Property
Nice sample of custom dependency object here (bottom)

Silverlight 4 Validation

This two-part series sums it up:
http://www.silverlightshow.net/items/The-validation-story-in-Silverlight-Part-1.aspx
http://www.silverlightshow.net/items/The-validation-story-in-Silverlight-Part-2.aspx

SL 3 supports ValidatesOnExceptions=True, NotifyOnValidationError=True
Throw exceptions in setters. Optionally use validation attributes on model properties: this requires Validator.ValidateProperty(value, new ValidationContext... in setter
Can use CustomValidation attribute and sdk:ValidationSummary tag

SL4 introduces IDataErrorInfo plus ValidatesOnDataErrors=True tag
and INotifyDataErrorInfo plus ValidatesOnNotifyDataErrors=True

Can customize the validation states in Blend: Default transition, Valid, InvalidUnfocused, InvalidFocused