[UWP开发]在windows10中设置壁纸~UserProfilePersonalizationSettings
在之前的wp8.1和wp8中,微软没有公开设置壁纸的API,只有一个设置锁屏的API,但在Windows10中,微软为我们提供了设置壁纸的API:TrySetWallpaperImageAsync,他定义在Windows.System.UserProfile.UserProfilePersonalizationSettings类中。
在使用前,需要调用UserProfilePersonalizationSettings.IsSupported()来检测当前环境是否允许自定义壁纸,如果可以的话,才能进行后续操作。
在设置壁纸的时候,针对壁纸文件的位置是有要求的,不能随意指定一个地址,经测试,放在Windows.Storage.ApplicationData.Current.LocalFolder中是可以的,但之前在10240中,也可以直接通过URI把项目文件夹中的图片设为壁纸(调用方法Windows.Storage.StorageFile.GetFileFromApplicationUriAsync()),但是我在10586中测试时又发现行不通了,只能放在localfolder相关的位置。
- if (UserProfilePersonalizationSettings.IsSupported() == true)
- {
- await new MessageDialog("可以设置壁纸哦~").ShowAsync();
- var current = UserProfilePersonalizationSettings.Current;
- bool re = await current.TrySetWallpaperImageAsync(/*StorageFile*/);
- if (re == true)
- {
- await new MessageDialog("设置成功").ShowAsync();
- }
- else
- {
- await new MessageDialog("设置失败了").ShowAsync();
- }
- }
- else
- {
- await new MessageDialog("不支持设置壁纸哦~").ShowAsync();
- }
附上我的demo:设置壁纸.zip
[UWP开发]在windows10中设置壁纸~UserProfilePersonalizationSettings的更多相关文章
- IOS开发—IOS 8 中设置applicationIconBadgeNumber和消息推送
摘要 在IOS7中设置applicationIconBadgeNumber不会有什么问题,但是直接在IOS8中设置applicationIconBadgeNumber会报错 因为在IOS8中要想设置a ...
- 【转】IOS开发—IOS 8 中设置applicationIconBadgeNumber和消息推送
在IOS7中设置applicationIconBadgeNumber不会有什么问题,但是直接在IOS8中设置applicationIconBadgeNumber会报错 因为在IOS8中要想设置appl ...
- nodejs 在windows10中设置动态(视频)壁纸
github 项目地址 node版本 λ node -v v12.16.2 main.js const ffi = require("@saleae/ffi"); const ch ...
- (UWP开发)在ListView中通过向右滑动展开汉堡菜单
首先在移动APP开发中,手势滑动已经成为一个必备的技能,无论大大小小的APP都需要拥有手势滑动功能.在Android和iOS操作系统的APP中,手势滑动比较普及.然而由于国内有关UWP应用的教程比较少 ...
- (UWP开发)基于Windows10 Anniversary SDK创造出位于可视化层的DropShadow
Windows.UI.Composition API是可以从任何通用Windows平台应用程序调用的声明性保留模式API,从而可以直接在应用程序中创建合成对象.动画和效果. Composition A ...
- UWP开发:存储容器设置&复合设置数据
有时候为了将应用设置进行分类,需要创建新的容器进行存储应用设置的信息. 1,容器的创建:在一个根容器里嵌套一个新容器 1)首先获取根容器. 2)调用ApplicationDataContainer.C ...
- Windows10(uwp)开发中的侧滑
还是在持续的开发一款Windows10的应用中,除了上篇博客讲讲我在Windows10(uwp)开发中遇到的一些坑,其实还有很多不完善的地方,比如(UIElement.Foreground).(Gra ...
- Win 10 UWP开发系列:设置AppBarButton的图标
在WP8以前,页面最下面的四个小圆按钮是不支持绑定的,WP8.1 RT之后,系统按钮升级成了AppBarButton,并且支持绑定了.在Win10 UWP开发中,按钮的样式发生了变化,外面的圆圈没有了 ...
- Win10 UWP开发中的重复性静态UI绘制小技巧 2
小技巧1 地址:http://www.cnblogs.com/ms-uap/p/4641419.html 介绍 我们在上一篇博文中展示了通过Shape.Stroke族属性实现静态重复性UI绘制,使得U ...
随机推荐
- centos7使用tinyproxy搭建简单http(s)服务器,无用户密码验证
1 安装 yum install tinyproxy 2 查找配置文件地址 whereis tinyproxy.conf 3 编辑配置文件 vim tinyproxy.conf 把 allow 12 ...
- Best free online svn repositories
Maybe you want to develop in a custom team environment or you usualy work on different machines (tha ...
- spring错误处理 Build path is incomplete. Cannot find class file for org.springframework.aop.Advisor
Build path is incomplete. Cannot find class file for org.springframework.aop.Advisor 初学spring,记录一下出现 ...
- editplus 链接FTP失败,超时
最近在用editplus链接服务器是出现了超时连接不上的情况 检查后发现FTP配置没问题 后来打开高级设置后发现没有配置端口号 配置后登陆成功
- python常用option
[python常用option] 1. -c cmd : program passed in as string (terminates option list) 解析字符串命令,不读cmd之后的op ...
- Binary Watch二进制时间
[抄题]: A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the b ...
- PHP语言性能优化——少使用魔术方法
对以下使用魔术方法和不适用魔术方法运行时间进行比较 使用魔术方法test1.php: <?php /** * 测试类 */ class test { private $name = " ...
- 常见的http response
200 //OK 400 //bad request 401 //Una ...
- Mac之如何查看已用端口
一.苹果自带的网络分析工具查看方法: OS X 10.9 下面 网络实用工具 从实用工具目录里消失了,可能苹果认为这个程序用的人太少就取消了吧.但是对于做互联网的人还是有点用的. 启动方法 ...
- Appium自动化测试-iOS
Appium的哲学 我们相信,对原生应用的自动化测试,应当不必要包含其他的SDK组件或者特别编译您的App,并且应当可以选择任何您喜欢的测试方法,框架和工具.基于这些出发点我们开发了Appium.现在 ...