다음을 통해 공유


UserProfilePersonalizationSettings.TrySetWallpaperImageAsync 메서드

정의

지정된 이미지 파일을 바탕 화면 배경 화면 이미지로 설정하려고 시도합니다.

public:
 virtual IAsyncOperation<bool> ^ TrySetWallpaperImageAsync(StorageFile ^ imageFile) = TrySetWallpaperImageAsync;
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncOperation<bool> TrySetWallpaperImageAsync(StorageFile const& imageFile);
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperation<bool> TrySetWallpaperImageAsync(StorageFile imageFile);
function trySetWallpaperImageAsync(imageFile)
Public Function TrySetWallpaperImageAsync (imageFile As StorageFile) As IAsyncOperation(Of Boolean)

매개 변수

imageFile
StorageFile

바탕 화면 배경으로 설정할 이미지입니다.

반환

비동기 작업의 결과입니다. 배경 이미지가 성공적으로 설정되었으면 true입니다. 그렇지 않으면 false입니다.

특성

예제

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.TrySetWallpaperImageAsync(file);
   }
}

설명

참고

이미지를 두 번 이상 설정하면 새 이미지 파일의 이름이 이전에 설정한 이미지와 달라야 합니다. 이전 이미지와 이름이 같은 파일을 사용하여 새 이미지를 설정하면 실패합니다.

적용 대상