I show a list of champions in the game (league of legends), and when I click on one, it shows more information about that champion in other textboxes. I've tried to make it work, but I failed, how can I make this work?
API connection
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;
}
tried using this (champion page)
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;
}
Put this in the 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"/>
What am I doing wrong?