UserProfilePersonalizationSettings UserProfilePersonalizationSettings UserProfilePersonalizationSettings UserProfilePersonalizationSettings UserProfilePersonalizationSettings Class

Definition

Provides properties and methods to manage the user's desktop wallpaper and lock screen background image.

public : sealed class UserProfilePersonalizationSettings : IUserProfilePersonalizationSettings
struct winrt::Windows::System::UserProfile::UserProfilePersonalizationSettings : IUserProfilePersonalizationSettings
public sealed class UserProfilePersonalizationSettings : IUserProfilePersonalizationSettings
Public NotInheritable Class UserProfilePersonalizationSettings Implements IUserProfilePersonalizationSettings
// This class does not provide a public constructor.
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Examples

using Windows.System.UserProfile;

// Pass in a relative path to a file inside the local appdata folder 
async Task<bool> SetWallpaperAsync(string localAppDataFileName) 
{ 
    bool success = false;
    if (UserProfilePersonalizationSettings.IsSupported())
    {
        var uri = new Uri("ms-appx:///Local/" + localAppDataFileName);
        StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(uri);
        UserProfilePersonalizationSettings profileSettings = UserProfilePersonalizationSettings.Current;
        success = await profileSettings.TrySetLockScreenImageAsync(file);
    }
    return success;
} 

Remarks

To get an instance of this class, call the Current method.

Note

When you set an image more than once, the new image file must have a different name than the previously set image. If you set a new image using a file with the same name as the previous image, it will fail.

Properties

Current Current Current Current Current

Gets the current instance of UserProfilePersonalizationSettings.

Methods

IsSupported() IsSupported() IsSupported() IsSupported() IsSupported()

Gets a value that indicates whether changing the desktop and lock screen images is supported on the current device.

TrySetLockScreenImageAsync(StorageFile) TrySetLockScreenImageAsync(StorageFile) TrySetLockScreenImageAsync(StorageFile) TrySetLockScreenImageAsync(StorageFile) TrySetLockScreenImageAsync(StorageFile)

Attempts to set the specified image file as the lock screen background image.

TrySetWallpaperImageAsync(StorageFile) TrySetWallpaperImageAsync(StorageFile) TrySetWallpaperImageAsync(StorageFile) TrySetWallpaperImageAsync(StorageFile) TrySetWallpaperImageAsync(StorageFile)

Attempts to set the specified image file as the desktop wallpaper image.