我想在 C# 代码中显示确认框。我已经看到了上面的解决方案,但它向我显示了“是”的异常,因为“System.Nullable”不包含“是”的定义。我应该如何消除这个错误?
private void listBox1_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
if (sender is ListBoxItem)
{
ListBoxItem item = (ListBoxItem)sender;
Harvest_TimeSheetEntry entryToDelete = (Harvest_TimeSheetEntry)item.DataContext;
DialogResult dialogResult = System.Windows.Forms.MessageBox.Show("Are you sure?", "Delete Confirmation", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes) // error is here
{
Globals._globalController.harvestManager.deleteHarvestEntry(entryToDelete);
}
else
{
System.Windows.MessageBox.Show("Delete operation Terminated");
}
}
}