CommunityToolkit / CommunityToolkit/Windows
Crash when no DataTemplate is provided for ItemsSource Bindings in SettingsExpander
- Vorherrschende Sprache
- C#
- Sterne
- 1.1k
- Forks
- 166
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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.

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
```
Beitragsleitfaden
Rechercherichtung
Start with the SettingsExpander implementation and reproduce the issue using the provided XAML and ObservableCollection example. Run the packaged app from the Windows Start Menu, compare it with the Visual Studio launch, and verify that expanding an ItemsSource without a DataTemplate no longer crashes.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- csharp
- Bereich
- desktop, frontend
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100