CommunityToolkit / CommunityToolkit/Windows

Crash when no DataTemplate is provided for ItemsSource Bindings in SettingsExpander

Aperta
#191 14 commenti 0 reazioni 0 assegnatari Vedi su GitHub
bug components::controls::settingscontrols documentation
Lingua principale
C#
Stelle
1.1k
Fork
166
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Not sure if this was discussed already somewhere else ...
But (now) I use the prerelease v8.0.230823-rc of this repository (Same issue occurred with last 'experimental' version 0.0.18 from the 'CommunityToolkit.Labs' package).

When binding an ObservableCollection to the ItemsSource attribute of a SettingsExpander, everything works as expected - when started from VisualStudio IDE.

However, when I start the installed App from Windows Start Menu the Application crashes with the first click on the Expander. The Windows Event Logger shows Application Error code 0xc000027b.

![WinUi3AppError](https://github.com/CommunityToolkit/Windows/assets/16986510/f4350071-d285-48af-9160-dc4edfe72e92)

Steps to reproduce:
---------------------

I am using Visual Studio 2022 Version 17.7.2 with AppSdk and Build Tools installed. Made a fresh Solution with "WinUI 3 Desctop - packaged" - Template.

My XAML:
```



```

My Code behind:
```
namespace WinUi3Test {
///
/// An empty window that can be used on its own or navigated to within a Frame.
///
public sealed partial class MainWindow : Window, INotifyPropertyChanged {

private ObservableCollection _mylist = new() { "first", "second" };
public ObservableCollection MyList { get => _mylist; set => SetProperty( ref _mylist, value); }

public MainWindow() {
this.InitializeComponent();
}

public event PropertyChangedEventHandler PropertyChanged;

private bool SetProperty([NotNullIfNotNull(nameof(newValue))] ref T field, T newValue, [CallerMemberName] string propertyName = null) {
if (EqualityComparer.Default.Equals(field, newValue)) {
return false;
}
field = newValue;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
return true;
}

private static int i = 0;
private void Button_Click(object sender, RoutedEventArgs e) {
MyList.Add("next" + i++);
}

private void Button_Click_1(object sender, RoutedEventArgs e) {
MyList.Clear();
}
}
}

```

My (Test) Project XML:
```


WinExe
net6.0-windows10.0.19041.0
10.0.17763.0
WinUi3Test
app.manifest
x86;x64;ARM64
win10-x86;win10-x64;win10-arm64
win10-$(Platform).pubxml
true
true



















true

```

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia dall’implementazione di SettingsExpander e riproduci il problema usando l’esempio fornito con XAML e ObservableCollection. Esegui l’app pacchettizzata dal menu Start di Windows, confrontala con l’avvio da Visual Studio e verifica che l’espansione di un ItemsSource senza DataTemplate non causi più arresti anomali.

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

Valutazione

Stack tecnologico
csharp
Ambito
desktop, frontend
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.