我遵循此guide。 我能夠通過WCF EXCEPT圖像檢索ListBox中的所有東西。有人能幫助我嗎?無法通過Windows Phone 8中的WCF服務檢索圖像
這是我的課
public Tips()
{
//
// TODO: Add constructor logic here
//
}
public int TipsId { get; set; }
public string TipsTitle { get; set; }
public string TipsDescription { get; set; }
public string TipsImage { get; set; }
public string TipsCategory { get; set; }
public string ImageBind { get; set; }
Service.cs
hairtips = new Tips();
hairtips.TipsId = myReader.GetInt32(0);
hairtips.TipsTitle = myReader.GetString(1);
hairtips.TipsDescription = myReader.GetString(2);
hairtips.TipsImage = myReader.GetString(3);
hairtips.TipsCategory = myReader.GetString(4);
tips.Add(hairtips);
web服務之後。我的.xaml
<ListBox Height="650" HorizontalAlignment="Left" Margin="11,17,0,0" Name="listBox1" VerticalAlignment="Top" Width="434" >
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<TextBlock Name="LblTitle" HorizontalAlignment="Left" Margin="0,0,0,0" TextWrapping="Wrap" Text="{Binding TipsTitle}" VerticalAlignment="Top"/>
<TextBlock Name="LblDesc" HorizontalAlignment="Left" Margin="0,0,0,0" TextWrapping="Wrap" Text="{Binding TipsDescription}" VerticalAlignment="Top" Width="400"/>
<Image x:Name="ImageHair" HorizontalAlignment="Stretch" Height="100" Margin="0,0,0,0" VerticalAlignment="Top" Width="100" Source="{Binding TipsImage}" Stretch="Fill"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
我的.cs。我在imagebind部分下有錯誤。
public HairTips()
{
InitializeComponent();
string Category = "Hair";
TipsServiceClient svc = new TipsServiceClient();
svc.getHairTipsCompleted += new EventHandler<getHairTipsCompletedEventArgs>(svc_getHairTipsCompleted);
svc.getHairTipsAsync(Category);
}
void svc_getHairTipsCompleted(object sender, getHairTipsCompletedEventArgs e)
{
List<Tips> listOfTips = new List<Tips>();
foreach (var c in e.Result)
{
Tips tips = new Tips();
tips.TipsTitle = c.TipsTitle;
tips.TipsDescription = c.TipsDescription;
tips.TipsImage = c.TipsImage;
tips.ImageBind = new BitmapImage(new Uri(tips.TipsImage, UriKind.Absolute));
listOfTips.Add(tips);
}
listBox1.ItemsSource = listOfTips;
}
請幫助我,如果你知道如何做到這一點。非常感謝你
上調將是有益的任何異常的具體文本。 – lsuarez
「不能將類型'System.Windows.Media.Imaging.BitmapImage'隱式轉換爲'字符串'」這是我在tips.ImageBind = new BitmapImage(new Uri(tips.TipsImage,UriKind.Absolute))下得到的異常。 – Milky