Search code examples
silverlightdata-bindingfinduielementuielementcollection

Silverlight databinding to locate UIElements


Is it possible to locate UIElement(s) on the visual tree in silverlight by inspecting the databinding somehow for a business object being bound. What I want to do is locate elements using a lambda expression (or any other means) from the element being bound something like:

var uielements = FindAllUIElements ( (businessObject)=> { businessObject.Firstname; } );

Can anyone point me in the right direction please.


Solution

  • Spoke to the guys at microsoft Hammids suggestion was to: Walk the visual tree and call FrameworkElement.GetBindingExpression(DP) for all DPs on that element. The resulting BindingExpression class has a property called DataItem that you could use to see if you’re interested in that binding.