因此,我有一个包含3列的表(位置,现有记录,已提交)。当用户单击特定行时,将显示一个弹出窗口,允许用户更改“已提交”的值。因此,当弹出窗口关闭时,我想在表中查看更新的值。但是,尽管该值已在数据库中更新,但事实并非如此。有人可以告诉我代码在哪里出错吗?
我遵循了this的回答,但没有帮助我。
我的查看代码:
<DataGrid.Columns>
<DataGridTextColumn Width="Auto" Header="OnHand" Binding="{Binding Path= OnHand,Mode = TwoWay,UpdateSourceTrigger=PropertyChanged }" />
</DataGrid.Columns>
这是我填充网格的方式:
foreach (var item in inventoryList)
{
items.Add(new InventoryDto { location = item.location.Name, OnHand = item.OnHand.ToString(), committed = item.committed.ToString() });
}
InventoryDataGrid.ItemsSource = items;
这是课程:
class InventoryDto : INotifyPropertyChanged
{
public string location { get; set; }
public string onHand { get; set; }
public string committed { get; set; }
public InventoryDto()
{
}
public InventoryDto(string location, string OnHand, string committed, string productId)
{
this.location = location;
this.onHand = OnHand;
this.committed = committed;
}
public string OnHand
{
get
{
return onHand;
}
set
{
onHand = value;
OnPropertyChanged("OnHand");
}
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
#endregion
}