Wpf 在DataGridRow的DataContext中看不到更改

Wpf 在DataGridRow的DataContext中看不到更改,wpf,datagrid,Wpf,Datagrid,我将WPF DataGrid中特定行的DataContext设置为不同的对象。DataContext在“监视”窗口中已更改,但各种绑定列不反映该行已更改的DataContext 这是我的密码: Private Sub btnDataContextChange_Click(sender As Object, e As RoutedEventArgs) Handles btnDataContextChange.Click Dim row = dtgChildren.FindVisualChi

我将WPF DataGrid中特定行的DataContext设置为不同的对象。DataContext在“监视”窗口中已更改,但各种绑定列不反映该行已更改的DataContext

这是我的密码:

Private Sub btnDataContextChange_Click(sender As Object, e As RoutedEventArgs) Handles btnDataContextChange.Click
    Dim row = dtgChildren.FindVisualChild(Of DataGridRow)()
    row.DataContext = DBEntities.Persons.Single(Function(x) x.PersonID = 22)
End Sub

如何强制刷新绑定?

您实际上想做什么?我很确定你不应该这样做。@Sheridan他正试图这么做-更改DataGrid行的DataContext,并使绑定列反映更改的DataContext。我认为这行不通,因为DataGrid管理每个DataGridRow的DataContext。相反,您需要替换DataGrid.ItemsSource中的相应项,它将反映在网格中。例如,MyItems[DataGrid.SelectedIndex]=new Person。。。其中MyItems是ObservableCollection,DataGrid.ItemsSource绑定到MyItems