我用這個鏈接http://thibaud60.blogspot.com/2010/02/footer-on-wpf-datagrid-by-use-several.html來同步兩個DataGrid,但拖放列標題有時會有bug。WPF:A DataGrid同步B DataGrid with columnWith和DisplayIndex
數據網格具有三個柱:A1,A2,A3
乙數據網格具有三個柱:B1,B2,B3
我SetBinding喜歡:
Binding bindingWidth = new Binding();
bindingWidth.Mode = BindingMode.TwoWay;
bindingWidth.Source = A1;
bindingWidth.Path = new PropertyPath(DataGridColumn.WidthProperty);
BindingOperations.SetBinding(B1, DataGridColumn.WidthProperty, bindingWidth);
Binding bindingDisplayIndex = new Binding();
bindingDisplayIndex.Mode = BindingMode.TwoWay;
bindingDisplayIndex.Source = A1;
bindingDisplayIndex.Path = new PropertyPath(DataGridColumn.DisplayIndexProperty);
BindingOperations.SetBinding(B1, DataGridColumn.DisplayIndexProperty, bindingDisplayIndex);
通常這工作良好,
但我改變了A1 displayindex通過拖動列有時雙向綁定不起作用:
我拖着A3 TO A1位置不成功,但是B3會成功改變位置爲B1
A1.DisplayIndex!= B1.DisplayIndex?
爲什麼會發生這種情況?