我的代码:
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<Image Height="100" Width="105" Source="{Binding Icon}" VerticalAlignment="Top" OpacityMask="White" Stretch="Fill" />
<TextBlock Text="{Binding Name}" Style="{StaticResource PhoneTextSubtleStyle}"
Width="110" TextAlignment="Center"/>
<Image Source="{Binding ImageSrc}" Height="20" Width="20" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="0,-50,15,0" Stretch="Fill" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
interestrates = (from rts in xmlDocu.Descendants("Friend")
select new SampleCheckedData
{
Id = (string)rts.Element("userid"),
Name = (string)rts.Element("name"),
Icon = (string)rts.Element("imageurl"),
VisibleStatus = (string)rts.Element("visiblestatus"),
AppStatus = (string)rts.Element("loginstatus"),
}).ToList<SampleCheckedData>();
this.lstImages.ItemsSource = interestrates;
我能够正确绑定名称和图标。但是我需要将 Imagesrc 图像设置为好像 visiblestatus,Appstatus 展位是真实的,然后需要绑定一种类型的图像,否则需要通过代码绑定另一种类型的图像。如何实现这一点?