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

原文: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();
        }

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

时间: 2024-08-30 02:53:52

Winform与WPF对话框(MessageBox, Dialog)之比较的相关文章

逆天通用水印支持Winform,WPF,Web,WP,Win10。支持位置选择(9个位置 ==》[X])

好几天没上QQ了,今天上了个QQ,,额....额...貌似消息还挺多,没及时回复的还请见谅~~刚好昨天无聊把水印这快封装出来了,支持图片水印,文字水印,索引图水印和非索引图水印,支持位置选择(9个位置 ==>[X]).好吧不高兴屁话了,软件是WPF的(只满足我的需求,如果有需要可以出第个二版本),水印核心代码封装了个Helper类(通用:支持Winform,WPF,Web,WP,Win10)软件共享一下==>http://pan.baidu.com/s/1qWDwv4C 源码看下面 水印类 /

在Winform或WPF中System.Diagnostics.Process.Start的妙用

我们经常会遇到在Winform或是WPF中点击链接或按钮打开某个指定的网址, 或者是需要打开电脑中某个指定的硬盘分区及文件夹, 甚至是"控制面板"相关的东西, 那么如何做呢? 答案是使用System.Diagnostics.Process.Start().它的作用是调用外部的命令. 先来看看它的调用方法:Process.Start () Process.Start (ProcessStartInfo) Process.Start (String)Process.Start (Strin

给WPF的MessageBox启用视觉样式

WPF的MessageBox为什么会这样 我的一个同学跟我说:“WPF不是新一代技术吗?怎么连MessageBox都没WinForm 的好看?” 上图是Windows Forms 的MesssageBox 与WPF 的MessageBox 的对比,我们发现,WPF没有启用视觉样式. 有的朋友会问了,那既然WPF没有启用视觉样式,那为什么它的控件的外观和启用样式后一样呢? 原因是这样的,WPF控件的绘制方式和普通程序不一样,它是采用DirectX 进行绘制的,而MessageBox 是在调用Win

Winform,Wpf快捷键

基类 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Windows.Forms; 6 using System.Windows.Input; 7 using WUtilitiesV01.Controls; 8 9 namespace WUtilitiesV01.Services 10 { 11 public abstract

如何去掉WinForm或者WPF的最大化和最小化按钮

博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:如何去掉WinForm或者WPF的最大化和最小化按钮.

WinForm 与WPF 窗体之间的想到调用

先放置一个容器控件,并设计 好WinForm(或WPF)窗口 winform 调用 wpf ElementHost el = new ElementHost(); el.Dock = DockStyle.Fill; this.panelStation.Controls.Add(el); ucStationMess_WPF stat = new ucStationMess_WPF(); el.Child = stat; 其中,panelStation 为winform 的窗口控件 ucStatio

基于Winform、WPF等的客户端文件下载

有时候,我们用C#写一些客户端应用程序需要从服务器下载一些资源,如图片.dll.配置文件等.下面就来说一下,在Winform及WPF中如何下载文件. 我们的资源大多放在自己的网站上,或者从其他网站下载资源,我们需要给客户端一个URL,先给出代码: /// <summary> /// 下载文件 /// </summary> /// <param name="URL">下载文件地址</param> /// <param name=&qu

jQuery UI 对话框(Dialog) - 模态表单

<!doctype html><html lang="en"><head> <meta charset="utf-8"> <title>jQuery UI 对话框(Dialog) - 模态表单</title> <link rel="stylesheet" href="//apps.bdimg.com/libs/jqueryui/1.10.4/css/jquer

Winform and WPF 第二遍双击快捷方式或应用程序打开原来的应用程序而不新建一个实例[进程通信 1]

private void Window_Loaded(object sender, RoutedEventArgs e)         {             Process[] pro = Process.GetProcesses();             int n = pro.Where(p => p.ProcessName.Equals("进程名称")).Count();             if (n > 1)             {