WPF中的主从 [英] Master-Detail in wpf
问题描述
您好,我正在尝试为Master ID创建详细信息DataGrid
但是,当我输入新ID并尝试编辑详细信息DataGrid
时,新详细信息记录将从DataGrid
消失,但存储在DataTable
中,当我重新加载项目时可以看到它.
XAML
我正在使用CollectionViewSource
,它们显示的Master Detail场景很好,但是涉及更新时.
在这里,我创建了一条新记录,用户在其中输入新的ID和ID的新详细信息
效果很好.
Hello I am trying to create a details DataGrid
for a Master ID
However when I enter a new ID and try to edit the details DataGrid
the new details record disappears from the DataGrid
but is stored in the DataTable
and I can see it when I reload the project.
XAML
I am using CollectionViewSource
and they display the Master Detail scenario just fine but when it comes to updating.
Here I create a new record where the User inputs new ID and new Details for the ID
This works fine.
button click
{
CollectionViewSource vs = (CollectionViewSource)FindResource("CVSVouchers);
ObjectDataProvider odp = (ObjectDataProvider)FindResource("Vouchers");
DataView dv = (DataView)odp.Data;
dv.AddNew();
vs.View.MoveCurrentToLast();
}
我处理了Datagrids Row EditEnding
and I handle the Datagrids Row EditEnding
Datagrid RowEditEnding
{
DataGridRow gridrow = e.Row;
DataRowView drv = gridrow.Item as DataRowView;
DataSet.ExpensesRow ExpRow = drv.Row as DataSet.ExpensesRow;
actExpRow.VoucherSN = float.Parse(this.txtID.Text);
}
然后记录从DataGrid
消失,但保存在DateTable
中.
then the record disappears from the DataGrid
but is saved in the DateTable
.
推荐答案
看看:
WPF DataGrid实用示例 [
Have a look at:
WPF DataGrid Practical Examples[^]
Best regards
Espen Harlinn
这篇关于WPF中的主从的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!