CommunityToolkit / CommunityToolkit/Windows

DataGrid control not working when using XAML islands in a Win32 app

Aperta
#725 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
C#
Stelle
1.1k
Fork
166
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

### Describe the bug

DataGrid control not working when using XAML islands, adding a DataGrid control to be used with a XAML island from a C# Class Library in a Win32 project wont show up, the code compiles and runs fine except the control is not visible. Is it possible I am missing something ?

For instance adding this in a user control :

```








```

Then in my function which gets called by the Win32 app where I am creating a new window from my SampleWindow which contains the DataGrid results in a blank window.

```
#pragma warning disable IDE0060
public static int ShowWindow(nint args, int sizeBytes)
{
#pragma warning restore IDE0060

if (!Bootstrap.TryInitialize(0x00010007, string.Empty, new PackageVersion(), Bootstrap.InitializeOptions.None, out var hr) &&
!Bootstrap.TryInitialize(0x00010006, string.Empty, new PackageVersion(), Bootstrap.InitializeOptions.OnNoMatch_ShowUI, out hr))
return hr;

if (_app == null)
{
_app = new DummyApp(); // Optional: enables WinUI styles
DispatcherQueueController.CreateOnCurrentThread();
}

var _source = new DesktopWindowXamlSource();
_source.Initialize(Win32Interop.GetWindowIdFromWindow(args));

var window = new SampleWindow();
window.Title = "People Table";
window.Activate();

return 0;
}
```

### Steps to reproduce

```text
1. Add a DataGrid control in a User Control in a C# Class library.
2. Use it in a XAML island in a Win32 app.
3. Control wont show up.
```

### Expected behavior

DataGrid control is visible.

### Screenshots

How it looks when not using XAML island :

Image

How it looks from a XAML island :

Image

### Code Platform

- [ ] UWP
- [x] WinAppSDK / WinUI 3
- [ ] Web Assembly (WASM)
- [ ] Android
- [ ] iOS
- [ ] MacOS
- [ ] Linux / GTK

### Windows Build Number

- [ ] Windows 10 1809 (Build 17763)
- [ ] Windows 10 1903 (Build 18362)
- [ ] Windows 10 1909 (Build 18363)
- [ ] Windows 10 2004 (Build 19041)
- [ ] Windows 10 20H2 (Build 19042)
- [ ] Windows 10 21H1 (Build 19043)
- [ ] Windows 10 21H2 (Build 19044)
- [ ] Windows 10 22H2 (Build 19045)
- [ ] Windows 11 21H2 (Build 22000)
- [ ] Other (specify)

### Other Windows Build number

_No response_

### App minimum and target SDK version

- [ ] Windows 10, version 1809 (Build 17763)
- [ ] Windows 10, version 1903 (Build 18362)
- [ ] Windows 10, version 1909 (Build 18363)
- [x] Windows 10, version 2004 (Build 19041)
- [ ] Windows 10, version 2104 (Build 20348)
- [ ] Windows 11, version 22H2 (Build 22000)
- [ ] Other (specify)

### Other SDK version

_No response_

### Visual Studio Version

_No response_

### Visual Studio Build Number

_No response_

### Device form factor

_No response_

### Additional context

_No response_

### Help us help you

Yes, I'd like to be assigned to work on this item.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia riproducendo il problema dal DataGrid XAML fornito e dal punto di ingresso ShowWindow, concentrandoti sulla configurazione di DesktopWindowXamlSource e SampleWindow. Confronta il percorso XAML-island con l’esempio non-island funzionante e determina perché DataGrid è assente; il lavoro è completato quando il controllo viene visualizzato nell’host Win32.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
csharp
Ambito
desktop
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.