Thursday, July 29, 2010

Silverlight - Binding System uses Visual Tree

Recently I was working on a control where I need to re-arrange layout of passed in user controls, which alters visual tree structure. During this I found binding system relies on visual tree.

With example:


Page1
|
|--UserControl1
|--UserControl2
|--UserControl3

Transforms into

Custom Control
|
|-UserControl1
|-UserControl2
|-Page1
| |-UserControl3


Above page when passed to this custom control need to strip few controls and arrange in different layout. If Binding done at Page1 level, once you remove user controls to different place than this visual tree, bindings will not be resolved.

No comments: