15
我想在C#代碼中顯示確認框。我已經看到了上述解決方案,但它顯示我在'是'的例外,因爲'System.Nullable'不包含'是'的定義。我應該如何消除這個錯誤?C#中的確認框wpf
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");
}
}
}
@ user1130886感謝編輯 – Habib
以及如何使用它? –
編輯你的例子,有不同的類型,編輯'DialogResult messageBoxResult = ...'到'MessageBoxResult messageBoxResult = ...'或者相反並且在if子句中應該是'if(messageBoxResult == MessageBoxResult.Yes)' – vinsa