How do I create a message box with “Yes”, “No” choices and a DialogResult?

前端 未结 11 1881
时光取名叫无心
时光取名叫无心 2020-11-28 00:40

I want to make simple Yes/No choiced MessageBox, but I think it is nonsense to design a form for that. I thought I could use MessageBox, add buttons, etc. to accomplish this

11条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-28 01:18

    dynamic MsgResult = this.ShowMessageBox("Do you want to cancel all pending changes ?", "Cancel Changes", MessageBoxOption.YesNo);
    
    if (MsgResult == System.Windows.MessageBoxResult.Yes)
    {
        enter code here
    }
    else 
    {
        enter code here
    }
    

    Check more detail from here

提交回复
热议问题