In order to detect whether your application is executing as a result of being in a designer use the GetIsInDesignMode
method of DesignerProperties
as the following demonstrate.
C#
bool designTime = System.ComponentModel.DesignerProperties.GetIsInDesignMode(
new DependencyObject());
VB.NET
dim designTime as Boolean = DesignerProperties.GetIsInDesignMode(
New DependencyObject)