splat icon indicating copy to clipboard operation
splat copied to clipboard

PlatformModeDetector.InDesignMode() not working in WPF designer for nested UserControls

Open wldevries opened this issue 3 years ago • 0 comments

Describe the bug PlatformModeDetector.InDesignMode() returns incorrect information when used in controls that are used within a control you are working on in the WPF designer.

Steps To Reproduce Provide the steps to reproduce the behavior:

  1. Create UserControlA with an OnLoaded event handler guarded by PlatformModeDetector.InDesignMode() throwing an exception when left through
  2. Create UserControlB that has UserControlA hosted somewhere within it
  3. Observe the WPF designer with Control display option: Show all controls

Expected behavior Designer works

Screenshots Designer shows an error with a stacktrace leading up to the exception created in step 1 in the OnLoaded event handler.

Environment

  • OS: Windows 10
  • Version: 21H1
  • Device: x64
  • Splat: 13.1.42

Additional context The built in WPF method DesignerProperties.GetIsInDesignMode(this) just works, when that is used instead in the event handler of UserControlA things that should not be run in design mode are skipped.

wldevries avatar Nov 10 '21 08:11 wldevries