-
-
Notifications
You must be signed in to change notification settings - Fork 139
Fix PlatformModeDetector.InDesignMode() for nested WPF UserControls #1480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…roperty Co-authored-by: glennawatson <5834289+glennawatson@users.noreply.github.com>
| private const string WpfDesignerPropertiesType = "System.ComponentModel.DesignerProperties, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"; | ||
| private const string WpfDesignerPropertiesDesignModeMethod = "GetIsInDesignMode"; | ||
| private const string WpfDependencyPropertyType = "System.Windows.DependencyObject, WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"; | ||
| private const string WinFormsDesignerPropertiesType = "Windows.ApplicationModel.DesignMode, Windows, ContentType=WindowsRuntime"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deceptive name, this is not winforms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the comment to clarify that LicenseManager is a general .NET design-time detection mechanism, not WinForms-specific. (28df915)
|
@copilot fix the compile issues in the area. Error: /Users/runner/work/splat/splat/src/Splat.Drawing/DefaultPlatformModeDetector.cs(55,17): error SA1515: Single-line comment should be preceded by blank line (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1515.md) [/Users/runner/work/splat/splat/src/Splat.Drawing/Splat.Drawing.csproj::TargetFramework=net9.0-tvos]
|
Co-authored-by: glennawatson <5834289+glennawatson@users.noreply.github.com>
Fix PlatformModeDetector.InDesignMode() for nested WPF UserControls
Problem Analysis
PlatformModeDetectorandDefaultPlatformModeDetectorimplementationDependencyObjectand callsGetIsInDesignMode()on itDependencyObjectis not part of the visual tree, so it can't detect design mode for nested controlsDesignerProperties.IsInDesignToolstatic property insteadImplementation
DefaultPlatformModeDetectorto useIsInDesignToolproperty for WPF (process-level check)LicenseManager.UsageModefallback for WinForms and broader compatibilityPlatformModeDetector)Next Steps
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.