UserProfilePersonalizationSettings Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Provides properties and methods to manage the user's desktop wallpaper and lock screen background image.
public ref class UserProfilePersonalizationSettings sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class UserProfilePersonalizationSettings final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class UserProfilePersonalizationSettings
Public NotInheritable Class UserProfilePersonalizationSettings
- Inheritance
- Attributes
Windows requirements
Device family |
Windows 10 (introduced in 10.0.10240.0)
|
API contract |
Windows.Foundation.UniversalApiContract (introduced in v1.0)
|
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 |
Gets the current instance of UserProfilePersonalizationSettings. |
Methods
IsSupported() |
Gets a value that indicates whether changing the desktop and lock screen images is supported on the current device. |
TrySetLockScreenImageAsync(StorageFile) |
Attempts to set the specified image file as the lock screen background image. |
TrySetWallpaperImageAsync(StorageFile) |
Attempts to set the specified image file as the desktop wallpaper image. |