microsoft / microsoft/microsoft-ui-xaml

ResourceDictionary Controls trigger runtime error with embedded CanvasControl from Microsoft.Graphics.Win2D

Open
#10,541 2 comments 0 reactions 0 assignees View on GitHub
area-InkCanvas bug
Dominant language
C++
Stars
8.4k
Forks
942
Avg merge
2d 7h
Merged PRs (30d)
105

Description

### Describe the bug

Adding Microsoft.Graphics.Win2D to a Project and embedding a CanvasControl in a Window or even UserControl works great. However, when embedding a CanvasControl in a ResourceDictionary control, it results in a runtime error, which isn't consistent.

The attached solution demonstrates the issue. It is configured to show a CanvasControl in all 3 scenarios.

[Win2DSandbox.zip](https://github.com/user-attachments/files/19972851/Win2DSandbox.zip)

### Steps to reproduce the bug

Open provided solution and ensure packages are installed.
Build and run. See crash happen.

### Expected behavior

No crash

### Screenshots

_No response_

### NuGet package version

None

### Windows version

Windows 10 (21H2): Build 19044

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by opening the attached Win2DSandbox.zip solution and reproducing the crash after installing its packages. Compare the CanvasControl behavior in a Window, UserControl, and ResourceDictionary; done means the ResourceDictionary scenario runs without the reported runtime error, like the other two cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
desktop, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.