Thursday, March 31, 2011

Default constructor can be suppressed. But it is required for XAML instantiation

Well the title really say it all doesn't it. If you create a class with a constructor that takes any parameters then the compiler will not create the default constructor for you. In such a case if you try to create the object in XAML your code will compile (actually the BAML will be made so the compiler really doesn't know that you tried to call a default constructor when there isn't one) but you will get a runtime error in InitializeComponent(). Just so you know.

Enjoy!