Why have minimal user/handwritten code and do everything in XAML?
Posted
by
Mrk Mnl
on Programmers
See other posts from Programmers
or by Mrk Mnl
Published on 2010-10-13T23:51:49Z
Indexed on
2011/02/17
15:33 UTC
Read the original article
Hit count: 293
I feel the MVVM community has become overzealous like the OO programmers in the 90's - it is a misnomer MVVM is synonymous with no code. From my closed StackOverflow question:
Many times I come across posts here about someone trying to do the equivalent in XAML instead of code behind. Their only reason being they want to keep their code behind 'clean'. Correct me if I am wrong, but is not the case that:
XAML is compiled too - into BAML - then at runtime has to be parsed into code anyway. XAML can potentially have more runtime bugs as they will not be picked up by the compiler at compile time - from incorrect spellings - these bugs are also harder to debug. There already is code behind - like it or not InitializeComponent(); has to be run and the .g.i.cs file it is in contains a bunch of code though it may be hidden. Is it purely psychological? I suspect it is developers who come from a web background and like markup as opposed to code.
EDIT: I don't propose code behind instead of XAML - use both - I prefer to do my binding in XAML too - I am just against making every effort to avoid writing code behind esp in a WPF app - it should be a fusion of both to get the most out of it.
UPDATE: Its not even Microsoft's idea, every example on MSDN shows how you can do it in both.
© Programmers or respective owner