System.Windows.ni.dll中出现'System.Windows.Markup.XamlParseException'类型的第一次机会异常

时间:2013-09-11 04:20:34

标签: c# windows-phone-8

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>

1 个答案:

答案 0 :(得分:0)

你是否在没有异步的情况下尝试过它?此外,documentation中的示例使用EventArgs而不是RoutedEventArgs,但我不确定是否会导致您看到的异常。