I am trying to fetch information from an XML document that shows all of my xbox live friends information. What I want to do now is display there avatar in a image control that is created dynamically but I am not sure on how I could actually have that image show up on my app grid.
So far I have tried this to create a dynamic control using the gamertag and adding my custom text to it. This is the code so far:
string gamertag, avatarURL;
foreach (XElement elm in doc.Descendants().Elements("Friends"))
{
gamertag = elm.Element("Gamertag").Value;
avatarURL = elm.Element("AvatarLarge").Value;
Image friendimage = new Image();
friendimage.Name = gamertag.ToString() + "ImageControl";
BitmapImage AccountPicbitmap = new BitmapImage();
AccountPicbitmap.UriSource = new Uri(avatarURL);
friendimage.Source = AccountPicbitmap;
//Some code to display this control with the avatar image using the URL retrieved, I want to play these tiles side by side
}
Any suggestions on how I could do this? Thanks in advance!
UPDATE: I have added this control to my XAML and but I am getting some weird exceptions now: System.Runtime.Remoting.RemotingException [7756] Designer process terminated unexpectedly!
<ItemsControl HorizontalAlignment="Left" Height="100" VerticalAlignment="Top" Width="1249" Margin="55,484,0,0" ItemsSource="{Binding}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Image Source="{Binding avatarURL}" Name="{Binding GamerTag}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Now when I debug the app it goes into an infinite loop and throws an exception as well on Initialization
public MainPage()
{
this.InitializeComponent();
}