I have a userControl which starts a timer. It looks like the XAML designer is trying to call that code, which links to some back-end database stuff. I keep getting an unhanded exception error in the design screen.
Any ideas how I can stop the designer trying to run the code?
XAML designer will call the UserControl's constructor when loading in designer. In order to avoid this you can place a if condition as follows in your UserControl constructor
if(System.ComponentModel.DesignMode) return;
You can also check in this way
if (!System.ComponenyModel.DesignProperties.GetIsInDesignMode(this))
{ // write constructor code here }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With