In the previous wp8.1 and WP8, Microsoft did not publicly set the wallpaper API, only a set of lock screen API, but in WINDOWS10, Microsoft has provided us with the Api:trysetwallpaperimageasync to set the wallpaper, He is defined in the Windows.System.UserProfile.UserProfilePersonalizationSettings class.
Before you use it, you need to call userprofilepersonalizationsettings.issupported () to detect whether the current environment allows custom wallpapers, and if so, to perform subsequent operations.
In the setting of the wallpaper, the location of the wallpaper file is required, you can not arbitrarily specify an address, tested, It is possible to put it in Windows.Storage.ApplicationData.Current.LocalFolder, but previously in 10240, you can also set the image in the project folder as a wallpaper directly from the URI (calling method Windows.Storage.Storag Efile.getfilefromapplicationuriasync ()), but when I tested in 10586, I found it was not working, only in the Localfolder-related position.
if (userprofilepersonalizationsettings.issupported () = True) { await new Messagedialog ("can set wallpaper Oh ~"). Showasync (); var current = userprofilepersonalizationsettings.current; bool Re = await current. Trysetwallpaperimageasync (/*storagefile*/); if (re = = true) { await new Messagedialog ("set Success"). Showasync (); } else { await new Messagedialog ("Setup failed"). Showasync (); }} else{ await new Messagedialog ("Do not support setting wallpaper Oh ~"). Showasync ();}
Attach my Demo: Set wallpaper. zip
[UWP Dev] set wallpaper in Windows10 ~userprofilepersonalizationsettings