Detecting design mode using WPF in a static method

I am using WPF. I have a static class that performs some settings that are not available in development mode. This constructor is called by the window in design mode, as a result of which an exception is thrown.

How to determine the development mode in a static method, so I can call the corresponding development mode behavior?

The recommended approach does not work for static methods.


Edit:

The static constructor is called from xaml, so I cannot conditionally call it (unless I moved the call to code that I would 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
}
+5
source share
1 answer

xaml:

  • . , .
  • . , DesignerProperties.GetIsInDesignMode(yourwindow) , - , .
+4

All Articles