TextBox动态文本

时间:2015-02-23 10:19:11

标签: c# .net windows

我正在开发一个应用程序,我需要在facebook中设置一些用户数据。因此,使用WebAuthentication代理我会让用户登录,然后我获取信息并将其设置为文本框值。正确获取信息,但未在Textbox中设置值。我无法弄清楚原因。有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

动态设置TextBox文本WP8.1

这是我设置数据的功能。

async public void SignUpUsingFacebook(string response)
    {            
        if (Utility.isInternetAvailable())
        {
            try { MainPage.StartAnimation();
            MainPage.loaderGrid.Visibility = Visibility.Visible;
            }
            catch
            {
                setAnimation();
                StartAnimation();
                loaderGrid.Visibility = Visibility.Visible;
            }
            string token = response.Substring(response.IndexOf('=') + 1);
            string fbGetInfo = "https://graph.facebook.com/me?access_token=" + token;
            HttpResponseMessage msg = await new HttpClient().GetAsync(new Uri(fbGetInfo), HttpCompletionOption.ResponseContentRead);
            if (msg.IsSuccessStatusCode)
            {
                try
                {
                    string fbData = await msg.Content.ReadAsStringAsync();
                    JObject j = JObject.Parse(fbData);
                    string fbId = j["id"].ToString();
                    txt_user_Name.Text = fbId;
                    txt_user_Name.Visibility = Visibility.Collapsed;
                    txt_first_Name.Text = j["first_name"].ToString();
                    txt_last_Name.Text = j["last_name"].ToString();
                    txt_email_Address.Text = j["email"].ToString();
                    txt_retype_email_Address.Text = j["email"].ToString();
                    gender = j["gender"].ToString();
                    if (gender.Equals("male", StringComparison.OrdinalIgnoreCase) || gender.Equals("boy", StringComparison.OrdinalIgnoreCase))
                    {
                        boy.Visibility = Visibility.Collapsed;
                        boySelected.Visibility = Visibility.Visible;
                        girlSelected.Visibility = Visibility.Collapsed;
                        girl.Visibility = Visibility.Visible;
                    }
                    else if (gender.Equals("female", StringComparison.OrdinalIgnoreCase) || gender.Equals("girl", StringComparison.OrdinalIgnoreCase))
                    {
                        girlSelected.Visibility = Visibility.Visible;
                        boySelected.Visibility = Visibility.Collapsed;
                        girl.Visibility = Visibility.Collapsed;
                        boy.Visibility = Visibility.Visible;
                    }
                }
                catch { }