私の問題は、ComboBox 編集から TextBlock 更新までの選択変更イベントのタイミングを計れないように見えることです。すべてがプロパティを表示しますが、コード ビハインドの SelectionChanged イベントで Grade を取得すると、実際の値で更新されません。実際の値を取得するには、ComboBox の選択を変更してから、編集中のデータグリッドの行をクリックする必要があります。次に、新しいグレードを選択すると、最後に選択されたグレードが表示されるように更新されます。したがって、すべてが接続されているように見えても、別の ComboBox を選択した場合とは対照的に、行をクリックするまで実際には行は更新されません。それでは、データグリッドがデータを更新して ComboBox との同期を維持する方法を変更する方法はありますか? どんな助けでも大歓迎です。ありがとう。
<DataGridTemplateColumn Header="Grade" CellStyle="{StaticResource StarNumberCellStyle}">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Grade}" Margin="3,1,3,1">
</TextBlock>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<ComboBox ItemsSource="{Binding DataContext.Grades, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}}}"
SelectedItem="{Binding Grade,Mode=TwoWay, NotifyOnTargetUpdated=True}" Tag="{Binding}" ComboBox.IsTextSearchEnabled = "True">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding DataContext.GradeSelectCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}}}"
CommandParameter ="{Binding}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>