Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there anyway to stop automatic DataContext inheritance in Silverlight?

Is there anyway to stop automatic DataContext inheritance in Silverlight?

I Set my DataContext on my parent UserControl in code. As a result all the xaml bindings inside the UserControl try to bind to the new DataConext they get (through the automatic DataContext Inheritance).

The DataContext's for the children elements (actually they are children of children of children) of the UserControl is something I need to set in the UserControl's code... I don't want them being all smart because they end up binding to the wrong data object! :-)

like image 925
Anthony Truskinger Avatar asked Apr 03 '10 05:04

Anthony Truskinger


1 Answers

Can you set the DataContext to {x:Null} in XAML, or null in code, for the items you don't want the inherited context for?

like image 75
Jeff Wilcox Avatar answered Oct 20 '22 11:10

Jeff Wilcox