"WIN10 Application Development" Custom desktop wallpaper

Source: Internet
Author: User

Calling a generic API to set up a desktop wallpaper is a simple and fun thing to combine with XAML to generate image features, and you can even do an app that lets users make a custom wallpaper from the photos he takes, and then as a desktop wallpaper.

This API is generic and can be used on any Windows device, including mobile phones, of course. Under the Windows.System.UserProfile namespace, there is a class called userprofilepersonalizationsettings, which can modify the lock screen wallpaper and desktop wallpaper, after the call will return a bool value, if the success is true, if the character is not good to return False

Before calling the Userprofilepersonalizationsettings class, first visit the IsSupported method to see if the operation is supported. You can then get a userprofilepersonalizationsettings instance through the current property, and then you can set the wallpaper.

Call the Trysetlockscreenimageasync method to set the lock screen wallpaper, call the Trysetwallpaperimageasync method to set the desktop wallpaper, parameters are used as the background of the picture file of the storagefile.

As you can see from this, it is really easy to use and show you an example:

            //Set Wallpaper            if(!userprofilepersonalizationsettings.issupported ()) {MsgBox. Content="character problem, unsupported operation. "; awaitMsgBox.                Showasync (); return; } userprofilepersonalizationsettings Settings=userprofilepersonalizationsettings.current; BOOLb =awaitsettings.            Trysetwallpaperimageasync (file); if(b) {MsgBox. Content="Setup succeeded. "; }            Else{MsgBox. Content="The operation failed. "; }

Look at the effect. Running on the PC is like this.

Running on the phone is like this.

Then to set the phone desktop wallpaper as an example, after modifying the wallpaper Start screen is like this.

How, isn't it very simple.

Example: Http://files.cnblogs.com/files/tcjiaan/CustomWallpage.zip

"WIN10 Application Development" Custom desktop wallpaper

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.