0

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?

Tendeza
  • 5
  • 2
  • *What am I doing wrong?* - What's actually going wrong? – Caius Jard Jan 19 '20 at 23:20
  • @CaiusJard I get 2 error's saying "Invalid binding path 'SelectedChamp.Name' : Property SelectedChamp not foung on type DataTemplate". Same exact one for "SelectedChamp.Title" – Tendeza Jan 20 '20 at 00:28

0 Answers0