C#代码如下
public partial class zoom1: PhoneApplicationPage
{
// Constructor
public zoom1()
{
InitializeComponent(); //the erroe is shown here
}
private async void SetBackground1(object sender, RoutedEventArgs e)
{
if (await LockScreenManager.RequestAccessAsync() == LockScreenRequestResult.Granted)
{
var uri = new Uri("ms-appx:///Assets/LockScreens/People/1.jpg", UriKind.Absolute);
LockScreen.SetImageUri(uri);
MessageBox.Show("Your new lockscreen background has been set.");
}
else
{
MessageBox.Show("You said no, so I can't update your background.");
}
}
}
将 click="" 添加到 AppBarButton 后生成错误。XAML 代码如下
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" Opacity="0.5" IsMenuEnabled="True">
<shell:ApplicationBarIconButton IconUri="Assets/Buttons/Check.png" Text="Set" Click="SetBackground1"/>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>