This article explains how you can get DesignMode. Especially, it’ll help don’t break VS Design View and Blend Design View. Also you’ll learn how to set and track IsInDesignMode property in your code.
In many different situation you need to get some data in constructor or OnLoad event, such as: some settings, data from database (I know it’s bad way load big amount of data in main thread) ect.
In these cases VS Design View and Blend Design View is broke. Last day I needed to do this in my project so it was necessary check if the code was executing in Design Mode.
So instead of looking up a DependencyProperty through the AppDomain data context by name, you can check the DependencyProperty defined in the DesignerProperties class.
You can get this value in your code like this:
Content = “In Design Mode”;
Content = “Runtime”;
So if you have some of these case in your code I suggest use following in code before of all:
It doesn’t crash Design View in Visual Studio and Blend.
BTW: you can set DesignMode:
And Track Changes to the IsInDesignMode Property through the overriding OnPropertyChanged event.