。在您的命令中,您可以輕鬆訪問您的下劃線數據,並檢查您的「發佈」屬性以及您的文件,並從收藏中刪除該行。
<Buttons Command="{Binding WriteCommand}" CommandParameter="{Binding ElementName=MyDataGridCtrl, Path=SelectedItem}" />
,如果你有一個DataTable作爲數據源的命令可能看起來像下面
private DelegateCommand<DataRowView> _writeCommand ;
public ICommand WriteCommand
{
get
{
return this._writeCommand ??
(this._writeCommand = new DelegateCommand<DataRowView>(this.WriteCommandExecute, this.CanWriteCommandExecute));
}
}
private bool CanEditDataCommandExecute(DataRowView rowToWrite)
{
return rowToWrite!= null && (bool)rowToWrite["Post"];//if post is a bool
}
private void EditDataCommandExecute(DataRowView rowToWrite)
{
if (!this.CanEditDataCommandExecute(rowToWrite))
return;
//do your stuff here
}
我找到了答案,'System.Windows.Controls.DataGrid的數據網格=發件人作爲System.Windows.Controls。數據網格; DataGridRow row =(DataGridRow)dataGrid.ItemContainerGenerator.ContainerFromItem(e.Row.Item); DataGridRow row =(DataGridRow)dataGrid.ItemContainerGenerator.ContainerFromItem(e.Row.Item); BridgeDesktopApp.SalesOrder nn =(SalesOrder)row.Item; int xcxc = nn.orderId;' – CPM 2011-04-12 13:17:05