码迷,mamicode.com
首页 > Windows程序 > 详细

Winform与WPF对话框(MessageBox, Dialog)之比较

时间:2018-09-05 09:19:05      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:win32   soft   winform   win   line   ros   ota   route   send   

原文:Winform与WPF对话框(MessageBox, Dialog)之比较

Winform:使用System.Windows.Forms命名空间中相应控件; WPF则调用Microsoft.Win32。

MessageBox:
// WinForm
        private void WFMessageBoxClicked(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.MessageBox.Show("Hello from Windows Forms!", "Hello World!");
        }

// WPF
        private void WPFMessageBoxClicked(object sender, RoutedEventArgs e)
        {
            System.Windows.MessageBox.Show("Hello from WPF!", "Hello world!");
        }

OpenFileDialog / SaveFileDialog:

// WinForm
        private void WinFormsDialogClicked(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.OpenFileDialog dialogOpenFile = new System.Windows.Forms.OpenFileDialog();
            dialogOpenFile.ShowDialog();

            //System.Windows.Forms.SaveFileDialog dialogSaveFile = new System.Windows.Forms.SaveFileDialog();
            //dialogSaveFile.ShowDialog();
        }

// WPF
        private void WPFDialogClicked(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog dialogOpenFile = new Microsoft.Win32.OpenFileDialog();
            dialogOpenFile.ShowDialog();

            //Microsoft.Win32.SaveFileDialog dialogSaveFile = new Microsoft.Win32.SaveFileDialog();
            //dialogSaveFile.ShowDialog();
        }

Winform与WPF对话框(MessageBox, Dialog)之比较

标签:win32   soft   winform   win   line   ros   ota   route   send   

原文地址:https://www.cnblogs.com/lonelyxmas/p/9589385.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!