1. 一个应用程序可以提供以下四项内容在锁定屏幕:
a. 背景图像。
b. 一个 24 x 24 pixel PNG 应用程序图标
c. 一个应用程序计数
d. 一串文本字符串
2. 用XML (Text) Editor打开WPAppManifest.xaml;在</Token>后面添加类似如下代码:
<Extensions>
<Extension ExtensionName="LockScreen_Wallpaper" ConsumerID="{111DFF24-AA15-4A96-8006-2BFF8122084F}" TaskID="_default" />
<Extension ExtensionName="LockScreen_Notification_IconCount" ConsumerID="{111DFF24-AA15-4A96-8006-2BFF8122084F}" TaskID="_default" />
<Extension ExtensionName="LockScreen_Notification_TextField" ConsumerID="{111DFF24-AA15-4A96-8006-2BFF8122084F}" TaskID="_default" />
</Extensions>
3. 通过LockScreenWallpaperManager 类来实现,添加代码改变锁定屏幕背景。
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());
}
}
a. 背景图像。
b. 一个 24 x 24 pixel PNG 应用程序图标
c. 一个应用程序计数
d. 一串文本字符串
2. 用XML (Text) Editor打开WPAppManifest.xaml;在</Token>后面添加类似如下代码:
<Extensions>
<Extension ExtensionName="LockScreen_Wallpaper" ConsumerID="{111DFF24-AA15-4A96-8006-2BFF8122084F}" TaskID="_default" />
<Extension ExtensionName="LockScreen_Notification_IconCount" ConsumerID="{111DFF24-AA15-4A96-8006-2BFF8122084F}" TaskID="_default" />
<Extension ExtensionName="LockScreen_Notification_TextField" ConsumerID="{111DFF24-AA15-4A96-8006-2BFF8122084F}" TaskID="_default" />
</Extensions>
3. 通过LockScreenWallpaperManager 类来实现,添加代码改变锁定屏幕背景。
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());
}
}