0

我显示了游戏中的英雄列表(英雄联盟),当我单击一个时,它会在其他文本框中显示有关该英雄的更多信息。我试图让它工作,但我失败了,我怎样才能让它工作?

API 连接

public static async Task<Champions> GetChamp()
        {
            Uri request = new Uri(@"http://ddragon.leagueoflegends.com/cdn/9.24.2/data/en_US/champion.json");

            HttpClient client = new HttpClient();
            client.DefaultRequestHeaders.Add("User-Agent", "RiotApi");
            HttpResponseMessage respons = await client.GetAsync(request);
            if (respons.IsSuccessStatusCode == false)
            {
                MessageDialog md = new MessageDialog("Can't find any champions");
                await md.ShowAsync();
                return null;
            }

            respons.EnsureSuccessStatusCode();
            string jsonstring = await respons.Content.ReadAsStringAsync();

            Champions mc = JsonConvert.DeserializeObject<Champions>(jsonstring);

            return mc;
        }

尝试使用这个(冠军页面)

private Champion _selectedchamp = new Champion();

public Champion SelectedChamp
{
    get { return _selectedchamp; }
    set { _selectedchamp = value; NotifyPropertyChanged(); }
}

private void ListView_ItemClick(object sender, ItemClickEventArgs e)
{
    SelectedChamp = e.ClickedItem as Champion;
}

把它放在 xaml

<TextBox Header="Naam" Text="{x:Bind SelectedChamp.Name, Mode=OneWay}" FontSize="16"/>
<TextBox Header="Title" Text="{x:Bind SelectedChamp.Title, Mode=OneWay}" FontSize="10"/>

我究竟做错了什么?

4

0 回答 0