Delen via


DesignMode.DesignMode2Enabled Property

Definition

Used to enable or disable user code inside a XAML designer that targets the Windows 10 Fall Creators Update SDK, or later.

public:
 static property bool DesignMode2Enabled { bool get(); };
static bool DesignMode2Enabled();
public static bool DesignMode2Enabled { get; }
var boolean = DesignMode.designMode2Enabled;
Public Shared ReadOnly Property DesignMode2Enabled As Boolean

Property Value

Boolean

bool

True if called from code running inside a XAML designer that targets the Windows 10 Fall Creators Update, or later; otherwise false.

Windows requirements

Device family
Windows 10 Fall Creators Update (introduced in 10.0.16299.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v5.0)

Examples

The following code only executes when running inside a XAML designer, regardless of the version of the SDK that the XAML designer targets. We recommend this check for most users.

if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
{
    // Code to execute when running inside a XAML designer, regardless of the SDK the designer targets.
}

The following code only executes when running inside a XAML designer that targets the Windows 10 Fall Creators Update SDK or later.

if (Windows.ApplicationModel.DesignMode.DesignMode2Enabled)
{
    // Code to execute when running inside a XAML designer that targets the Fall Creators Update SDK, or later.
}

Remarks

Windows.ApplicationModel.DesignMode.DesignModeEnabled returns true when called from user code running inside any version of the XAML designer--regardless of which SDK version you target. This check is recommended for most users.

Starting with the Windows 10 Fall Creators Update, Visual Studio provides a new XAML designer that targets the Windows 10 Fall Creators Update and later.

Use Windows.ApplicationModel.DesignMode.DesignMode2Enabled to differentiate code that depends on functionality only enabled for a XAML designer that targets the Windows 10 Fall Creators Update SDK or later.

The following table lists differences in functionality supported by the XAML designer, depending on the version of the Windows 10 SDK that the XAML designer targets.

XAML designer that targets the Windows 10 Creators Update SDK or earlier Xaml designer that targets the Windows 10 Fall Creators Update SDK or later
CoreWindow ✔️
CoreDispatcher ✔️
Threading model Single-threaded apartment (STA) Application single-threaded apartment (ASTA)
.NET Framework Desktop Core
UI Composition support ✔️
Acrylic brush support ✔️
Fluent design system Limited Full support

Applies to

See also