내 모든 Xbox 라이브 친구 정보를 보여주는 XML 문서에서 정보를 가져 오려고합니다. 지금하고 싶은 것은 동적으로 생성 된 이미지 컨트롤에 아바타를 표시하는 것입니다.하지만 실제로 어떻게 그 이미지가 내 앱 그리드에 표시 될지 확신 할 수 없습니다.동적 이미지 컨트롤 메트로 앱을 만드는 방법
지금까지 나는 게이머 태그를 사용하고 사용자 정의 텍스트를 추가하여 동적 컨트롤을 만들려고 시도했습니다. 지금까지 코드 :
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
}
내가 어떻게 할 수 있습니까? 미리 감사드립니다!
UPDATE : 가 내 XAML에이 컨트롤을 추가하고 있지만, 지금은 몇 가지 이상한 예외를 얻고있다 : System.Runtime.Remoting.RemotingException 을 [7756] 디자이너 프로세스가 예기치 않게 종료!
<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>
내가 응용 프로그램을 디버깅 할 때 지금은 무한 루프로 전환되고이이 같은 XAML 뭔가 할 쉬울 것
public MainPage()
{
this.InitializeComponent();
}
가 왜 XAML에서이 일을하지 않습니다 : 뒤에
코드는 다음과 같이해야 하는가? xaml에서 이와 같은 작업을 쉽게 수행 할 수 있습니다. – mydogisbox
글쎄, 내가 xaml 디자인을 가지고 있지만 이것은 코드 배후입니다. xaml을 어떻게 사용합니까? – KPS