Fix BindingError bei Group.IsDifferentiated in GroupDetailView
Group ist beim ersten Binden der View noch null (LoadGroup läuft erst danach), wodurch der verschachtelte Pfad "Group.IsDifferentiated" bei jeder Navigation einen Binding-Fehler loggte. Stattdessen jetzt eine eigene IsDifferentiated-Property auf GroupDetailViewModel.
This commit is contained in:
@@ -167,6 +167,13 @@ public partial class GroupDetailViewModel : ObservableObject
|
||||
[ObservableProperty] private StudentSummary? _selectedStudent;
|
||||
[ObservableProperty] private ExamSummary? _selectedExam;
|
||||
|
||||
// Eigene Property statt "Group.IsDifferentiated" im Binding-Pfad: die View bindet bereits,
|
||||
// bevor LoadGroup() läuft (siehe MainWindowViewModel.NavigateToGroupDetail), Group ist dann
|
||||
// kurzzeitig null — ein verschachtelter Pfad würde dafür jedes Mal einen Binding-Fehler loggen.
|
||||
public bool IsDifferentiated => Group?.IsDifferentiated ?? false;
|
||||
|
||||
partial void OnGroupChanged(LearningGroup? value) => OnPropertyChanged(nameof(IsDifferentiated));
|
||||
|
||||
public ObservableCollection<StudentSummary> Students { get; } = [];
|
||||
public ObservableCollection<ExamSummary> Exams { get; } = [];
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
<DataGridTextColumn Header="Name" Binding="{Binding FullName}" Width="*"/>
|
||||
<DataGridTextColumn Header="Zeitraum" Binding="{Binding PeriodLabel}" Width="90"/>
|
||||
<DataGridTemplateColumn Header="Niveau" Width="130"
|
||||
IsVisible="{Binding Group.IsDifferentiated}">
|
||||
IsVisible="{Binding IsDifferentiated}">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate x:DataType="vm:StudentSummary">
|
||||
<ComboBox ItemsSource="{x:Static vm:StudentSummary.NiveauOptions}"
|
||||
@@ -110,7 +110,7 @@
|
||||
<DataGridTextColumn Header="Datum" Binding="{Binding Date}" Width="110"/>
|
||||
<DataGridTextColumn Header="Titel" Binding="{Binding Title}" Width="*"/>
|
||||
<DataGridTextColumn Header="Niveau" Binding="{Binding NiveauLabel}" Width="80"
|
||||
IsVisible="{Binding Group.IsDifferentiated}"/>
|
||||
IsVisible="{Binding IsDifferentiated}"/>
|
||||
<DataGridTemplateColumn Header="Status" Width="150">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate x:DataType="vm:ExamSummary">
|
||||
|
||||
Reference in New Issue
Block a user