1

你好 :) 我马上就可以了。

问题:当我尝试实例化 LiveConnectClient 然后尝试访问事件时:假设在 LiveConnectClient 中的 GetCompleted 没有显示,并且在我一直在查看的所有示例中,甚至这里的示例都在使用它。这不是唯一发生在它上面的课程,它也在 LiveAuthClient 上发生,即使网络上的帖子说应该有,也没有任何事件。

我试图从头开始重新安装 Vs2012 和 sdk wp8 和 live sdk 但还没有解决

参考我使用这个例子来看看我是否可以工作:

    //event triggered when Skydrive sign in status is changed
    private void btnSignIn_SessionChanged(object sender, Microsoft.Live.Controls.LiveConnectSessionChangedEventArgs e)
    {
        //if the user is signed in
        if (e.Status == LiveConnectSessionStatus.Connected)
        {
            session = e.Session;

            client = new LiveConnectClient(e.Session);
            infoTextBlock.Text = "Accessing SkyDrive...";

            //get the folders in their skydrive

            client.GetCompleted +=
                new EventHandler<LiveOperationCompletedEventArgs>(btnSignin_GetCompleted);

            client.GetAsync("me/skydrive/files?filter=folders,albums");
        }

        //otherwise the user isn't signed in
        else
        {
            infoTextBlock.Text = "Not signed in.";
            client = null;
        }

    }

我没有运气解决它并且没有想法。所以我希望你们中的一个男孩能对此有所了解,或者用露珠的话伸出援助之手:)

提前致谢。如果这篇文章太长,我深表歉意。

问候詹斯

4

1 回答 1

2

事实上,这些事件似乎已在最新版本的 SDK 中被删除。不过,由于 async/await 关键字,您不需要它们。首先,将您的方法标记为,然后使用关键字async调用该GetAsync方法。await然后放置您通常会在GetCompleted事件中放入的代码:

private async void btnSignIn_SessionChanged(object sender, Microsoft.Live.Controls.LiveConnectSessionChangedEventArgs e)
{
    //if the user is signed in
    if (e.Status == LiveConnectSessionStatus.Connected)
    {
        session = e.Session;

        client = new LiveConnectClient(e.Session);
        infoTextBlock.Text = "Accessing SkyDrive...";

        //get the folders in their skydrive
        var result = await client.GetAsync("me/skydrive/files?filter=folders,albums");

        // Do here what you would normally do in btnSignin_GetCompleted
    }

    //otherwise the user isn't signed in
    else
    {
        infoTextBlock.Text = "Not signed in.";
        client = null;
    }

}
于 2013-01-14T21:26:12.463 回答