UserProfilePersonalizationSettings 类

定义

提供用于管理用户的桌面壁纸和锁屏界面背景图像的属性和方法。

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
继承
Object Platform::Object IInspectable UserProfilePersonalizationSettings
属性

Windows 要求

设备系列
Windows 10 (在 10.0.10240.0 中引入)
API contract
Windows.Foundation.UniversalApiContract (在 v1.0 中引入)

示例

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;
} 

注解

若要获取此类的实例,请调用 Current 方法。

注意

多次设置映像时,新映像文件的名称必须与以前设置的映像不同。 如果使用与上一个映像同名的文件设置新映像,它将失败。

属性

Current

获取 UserProfilePersonalizationSettings 的当前实例。

方法

IsSupported()

获取一个值,该值指示当前设备上是否支持更改桌面和锁屏界面图像。

TrySetLockScreenImageAsync(StorageFile)

尝试将指定的图像文件设置为锁屏背景图像。

TrySetWallpaperImageAsync(StorageFile)

尝试将指定的图像文件设置为桌面壁纸图像。

适用于