CommunityToolkit / CommunityToolkit/Windows
Crash when no DataTemplate is provided for ItemsSource Bindings in SettingsExpander
- Lenguaje dominante
- C#
- Estrellas
- 1.1k
- Forks
- 166
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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
```
Guía de contribución
Línea de trabajo
Comienza con la implementación de SettingsExpander y reproduce el problema usando el ejemplo proporcionado de XAML y ObservableCollection. Ejecuta la aplicación empaquetada desde el menú Inicio de Windows, compárala con el lanzamiento desde Visual Studio y verifica que expandir un ItemsSource sin DataTemplate ya no provoque un bloqueo.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- csharp
- Área
- desktop, frontend
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100