Is there a MessageBox equivalent in WPF?

前端 未结 9 972
耶瑟儿~
耶瑟儿~ 2020-11-29 17:49

Is there a standard message box in WPF, like WinForms\' System.Windows.Forms.MessageBox.Show(), or should I use the WinForms message box?

9条回答
  •  我在风中等你
    2020-11-29 18:13

    Maybe the code here below helps:

    using Windows.UI.Popups;
    namespace something.MyViewModels
    {
        public class TestViewModel
        {
            public void aRandonMethode()
            {
                MyMessageBox("aRandomMessage");
            }
    
            public async void MyMessageBox(string mytext)
            {
                var dialog = new MessageDialog(mytext);
                await dialog.ShowAsync();
            }
        }
    }
    

提交回复
热议问题