Where should I set the DataContext - code behind or xaml?

Posted by dovholuk on Stack Overflow See other posts from Stack Overflow or by dovholuk
Published on 2010-05-11T14:21:40Z Indexed on 2010/05/11 16:14 UTC
Read the original article Hit count: 154

Filed under:
|
|

(honestly I searched and read all the 'related questions' that seemed relevant - i do hope i didn't "miss" this question from elsewhere but here goes...)

There are two different ways (at least) to set the DataContext. One can use XAML or one can use the code behind.

What is the 'best practice' and why?

I tend to favor setting it in XAML because it allows a designer to define collections on their own but I need 'ammunition' on why it's a best practice or why I'm crazy and the code behind is the bomb...

© Stack Overflow or respective owner

Related posts about Silverlight

Related posts about datacontext