1,打开WMAppManifest.xml.添加

 <Extensions>
      <Extension ExtensionName="LockScreen_Wallpaper" ConsumerID="{111DFF24-AA15-4A96-8006-2BFF8122084F}" TaskID="_default" />
</Extensions>

 

 
2,添加事件

private async void buttonSet_Click(object sender, RoutedEventArgs e)
{
      Uri nextImageUri;
      nextImageUri = new Uri("file:///" + Windows.ApplicationModel.Package.Current.InstalledLocation.Path + "/DefaultWallpaper.jpg", UriKind.RelativeOrAbsolute);

      try
      {
            bool isProvider = Windows.Phone.System.UserProfile.LockScreenWallpaperManager.IsProvidedByCurrentApplication;
            if (isProvider)
            {
                  Windows.Phone.System.UserProfile.LockScreenWallpaper.SetImageUri(nextImageUri);
            }
            else
            {
                  var op = await LockScreenWallpaperManager.RequestAccessAsync();
            }
      }
      catch (System.Exception ex)
      {
            MessageBox.Show(ex.ToString());
      }
}
 
From SDK:
Lock screen background for Windows Phone


 

 

posted on 2012-08-21 15:46  微星  阅读(1153)  评论(0编辑  收藏  举报