I am using WPF. I have a static class that performs some setup not available during design mode. This constructor gets called by a window in design mode, which results in an exception being thrown.
How do I detect design mode in a static method, so I can invoke the appropriate design mode behavior?
The recommended approach does not work for static methods.
Edit:
The static constructor is called from xaml, so I can't conditionally call it (unless I move the call to code-behind, which I'd like to avoid).
In the window: <Window ... HelpProvider.Keyword="some_help_topic.html">
In the class:
static HelpProvider()
{
// Load the .chm file from an application setting (this fails at design time)
// Add a WPF command binding
}
The possible way to solve it keeping attached property in xaml file is:
DesignerProperties.GetIsInDesignMode(yourwindow)
there and decide, if you need to load file or whatever causes issues.