XAML or C# code-behind

user101375 picture user101375 · Jun 16, 2009 · Viewed 24.6k times · Source

I don't like to use XAML. I prefer to code everything in C#, but I think that I am doing things wrong.

In which cases it is better to use XAML and when do you use C#? What is your experience?

Answer

Will Eddins picture Will Eddins · Jun 16, 2009

Creating an entire window in C# can be a mess of code. The best thing about WPF is that XAML allows you to separate your design from your logic, making for much easier-to-read code.

I'll use C# when I need to create dynamic controls, but I tend to keep my general design, static storyboards, styles, datatemplates, etc. in XAML.