文件选择器

WPF:OpenFileDialog
Microsoft.Win32.OpenFileDialog openFileDialog = new();
bool? result = openFileDialog.ShowDialog();
if (result.HasValue&&result.Value)
FileName.Text = openFileDialog.FileName;
else
FileName.Text= null;
UWP:FileOpenPicker
FileOpenPicker picker = new FileOpenPicker();
picker.FileTypeFilter.Add("*");
StorageFile file = await picker.PickSingleFileAsync();
if (file!=null)
FileName.Text=file.Name;
else
FileName.Text = "";
WinUI:FileOpenPicker
FileOpenPicker fileOpenPicker = new FileOpenPicker();
IntPtr hwnd = WinRT.Interop.WindowNative.GetWindowHandle(this);
WinRT.Interop.InitializeWithWindow.Initialize(fileOpenPicker, hwnd);
fileOpenPicker.FileTypeFilter.Add("*");
StorageFile file = await fileOpenPicker.PickSingleFileAsync();
if (file != null)
FileName.Text = file.Name;
else
FileName.Text = "";
WinUI:FileOpenPicker
winrt::Windows::Storage::Pickers::FileOpenPicker FPK;
auto initializeWithWindow{ FPK.as<IInitializeWithWindow>() };
initializeWithWindow->Initialize(MYHWND);
FPK.SuggestedStartLocation(winrt::Windows::Storage::Pickers::PickerLocationId::MusicLibrary);
FPK.FileTypeFilter().Append(L"*");
winrt::Windows::Storage::StorageFile file = co_await FPK.PickSingleFileAsync();

异步线程更新UI

WPF:InvokeAsync
  await Dispatcher.InvokeAsync(() => { MyTextBlock.Text = "123"; });
UWP:RunAsync
 await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { MyTextBlock.Text = "123"; });
WinUI:TryEnqueue
 DispatcherQueue.TryEnqueue(Microsoft.UI.Dispatching.DispatcherQueuePriority.Normal, () => { MyTextBlock.Text = "123"; });

在WPF UWP WinUI中相同功能的用法的区别的更多相关文章

  1. Linux中yum和apt-get用法及区别

    Linux中yum和apt-get用法及区别   一般来说著名的linux系统基本上分两大类:   1.RedHat系列:Redhat.Centos.Fedora等   2.Debian系列:Debi ...

  2. Html A标签中 href 和 onclick用法、区别、优先级别

    原文:Html A标签中 href 和 onclick用法.区别.优先级别 如果不设置 href属性在IE6下面会不响应hover.双击后会选中标签的父容器而非这个一a标签(IE下都存在这一问题). ...

  3. WPF/UWP 绑定中的 UpdateSourceTrigger

    在开发 markdown-mail 时遇到了一些诡异的情况.代码是这么写的: <TextBox Text="{Binding Text, Mode=TwoWay}"/> ...

  4. java中List,Set,Map用法以及区别

    List,Set,Map是否继承自Collection接口? 答:List,Set是,Map不是. Collection是最基本的集合接口,一个Collection代表一组Object,即Collec ...

  5. VC中MessageBox与AfxMessageBox用法与区别

    一.MessageBox()用法 1.函数原型 Messagebox函数在Win32 API和MFC里的定义有区别. Win32 API的定义如下: int WINAPI MessageBox(    ...

  6. Python中eval与exec用法的区别

    Python中eval,exec这两个函数有着相似的输入参数类型和执行功能,因此在用法上经常出现混淆,以至经常用错,程序易抛出错误.下面主要通过这两个函数的语法来阐述区别,并用例子来进一步说明. 首先 ...

  7. A标签中 href 和 onclick用法、区别、优先级别

    (内容摘自:https://blog.csdn.net/chenchunlin526/article/details/77346049) Html A标签中 href 和 onclick 同时使用的问 ...

  8. SQL中IN和EXISTS用法的区别

    结论 1. in()适合B表比A表数据小的情况 2. exists()适合B表比A表数据大的情况 当A表数据与B表数据一样大时,in与exists效率差不多,可任选一个使用. select * fro ...

  9. Dom4j中getStringValue()和getText()用法的区别

    这两个方法都是获取文本的,区别是: getText()-----获取当前节点的文本内容,如果当前节点下是一个element元素,那返回的就是null. getStringValue------获取当前 ...

  10. 【转】VC中MessageBox与AfxMessageBox用法与区别

    原文网址:http://blog.csdn.net/holybin/article/details/28403109 一.MessageBox()用法 1.函数原型 Messagebox函数在Win3 ...

随机推荐

  1. 在鼠标右键菜单中新增新建Markdown文件选项(VSCode)

    引言 正常情况下,我们新建md文件有两种方式:一是通过Markdown编辑器新建,二是新建txt文件再修改后缀. 但是在Windows系统中,我们可以通过修改注册表来新增右键菜单选项.这里我们可以通过 ...

  2. 【python爬虫案例】用python爬豆瓣读书TOP250排行榜!

    目录 一.爬虫对象-豆瓣读书TOP250 二.python爬虫代码讲解 三.讲解视频 四.完整源码 一.爬虫对象-豆瓣读书TOP250 今天我们分享一期python爬虫案例讲解.爬取对象是,豆瓣读书T ...

  3. Linux中的touch命令

    Linux中一个文件有3种时间属性,分别是mtime,ctime,atime: modification time (mtime) 当该文件的『内容数据』变更时,就会升级这个时间!内容数据指的是文件的 ...

  4. NSThread的start方法内部做了什么?

    下面是NSThread start方法的汇编码: 1 1 1 ;Foundation`-[NSThread start]: 2 2 2 -> 0x7fff2594f47f <+0>: ...

  5. python的requests模块详解

    原文链接:https://www.cnblogs.com/lanyinhao/p/9634742.html 1.模块说明 requests是使用Apache2 licensed 许可证的HTTP库. ...

  6. uniapp video组件全屏导致页面横竖错乱问题

    uniapp video组件全屏导致页面横竖错乱问题 背景介绍 使用 video组件做一个视频播放功能,不全屏的情况正常.在苹果手机上全屏后,点击左上角退出全屏,页面出现问题如下图问题,主要系统iOS ...

  7. Linux搭建ESP-IDF开发环境

    下载esp-gitee-tools git clone git@gitee.com:EspressifSystems/esp-gitee-tools.git 替换github网址 cd esp-git ...

  8. 实用!!!!springBoot加入微信扫码支付功能,有一说一还是挺有意思的

    基于springboot微服务加入微信支付的功能 在线微信支付开发文档: https://pay.weixin.qq.com/wiki/doc/api/index.html native扫码支付方式: ...

  9. minio 安装

    mybatis 相关:https://baomidou.com/pages/223848/#fieldfillhttps://mybatis-flex.com/zh/intro/maven.html ...

  10. Smart - Luogu —— 智能的洛谷

    @ 目录 安装 Stylus 谷歌 Edge 安装 Smart - Luogu 使用 尾声 安装 Stylus link 点击推荐下载,获取 crx 文件 谷歌 先点击右上角三个点,再点击扩展程序,然 ...