WPF 打开文件对话框主题 [英] WPF Open FIle Dialog theme

查看:21
本文介绍了WPF 打开文件对话框主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的 WPF 应用程序中使用 Microsoft.Win32.OpenFileDialog 来选择文件:

var dlg = new Microsoft.Win32.OpenFileDialog{Title = "选择配置",DefaultExt = ".xml",Filter = "XML 文件 (.xml)|*.xml",CheckFileExists = true};if (dlg.ShowDialog() == true){//...}

根据 问题中添加清单不起作用.如何显示 MSDN 中的对话框?

首先,我对原生"解决方案感兴趣,而不是使用第三方组件.

解决方案

如果您将目标切换到 .Net 4.0 完整版或客户端配置文件,您将获得正确的对话框.

如果您使用 Windows 7 代码包,但是当您以 .Net 4.0 为目标时,可以使用新样式的打开对话框.

I'm using Microsoft.Win32.OpenFileDialog in my WPF application for selecting file:

var dlg = new Microsoft.Win32.OpenFileDialog
{
    Title = "Select configuration",
    DefaultExt = ".xml",
    Filter = "XML-file (.xml)|*.xml",
    CheckFileExists = true
};

if (dlg.ShowDialog() == true)
{
//...
}

According to MSDN screenshots on Windows 7 dialog must have modern style, but I'm getting the old one:

Adding manifest like in this question doesn't works. How to get dialogs like in MSDN shown?

EDIT:

First of all, I'm interested in "native" solution, not using third-party components.

解决方案

You will get the correct dialog if you switch your target to the .Net 4.0 full or client profile.

Some of the modern common dialogs are only available in WPF if you use the Windows 7 Code Pack, but the new style open dialog is available when you target .Net 4.0.

这篇关于WPF 打开文件对话框主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆