我不確定這裏有什麼問題,但是我的圖像沒有顯示出來。我的對象的所有其他屬性都顯示出來,但圖像從不加載。我已經嘗試瀏覽器中的網址,並在那裏顯示圖像。這裏是我的代碼:我的圖像沒有顯示在listcontrol中
使用MVVM燈,設置視圖模型
DataContext="{Binding Main, Source={StaticResource Locator}}">
我使用數據綁定
<ItemsControl ItemsSource="{Binding AllItems}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Height="200">
<!--<StackPanel.Background>
<ImageBrush ImageSource="PodImages\podstate-Clip.png" />
</StackPanel.Background>-->
<Image Source="{Binding ImageUri}"/>
<StackPanel Orientation="Horizontal">
<StackPanel>
<TextBlock Text="{Binding Summ}" FontSize="32" Foreground="Green"/>
<TextBlock Text="{Binding Brand}" FontSize="32" Foreground="Blue"/>
<TextBlock Text="{Binding L1}" Width="350" TextWrapping="Wrap" Foreground="Blue"/>
</StackPanel>
<TextBlock Text="{Binding Val}"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
我的數據模型
public class Offer
{
public long ID { get; set; }
public int Type { get; set; }
public string Summ { get; set; }
public string L1 { get; set; }
public string Brand { get; set; }
public string ImageUri { get; set; }
}
我的數據服務回調XAML 。這是按預期設置我的收藏。 ImageUri包含一個有效的URI。
private void OffersLoaded(OfferDetailsWithMsg offers)
{
AllItems = offers.Items.Where(item => item.Type == 0).ToList();
}
終於我的AllItems屬性。是的,我呼籲RaisePropertyChanged
(爲簡便起見移除支撐性)
public List<Offers> AllItems
{
get
{
return _allItems;
}
set
{
if (_allItems == value)
{
return;
}
_allItems= value;
RaisePropertyChanged(AllItemsPropertyName);
}
您是否檢查過頁面的源代碼? –
這是一個Windows Phone應用程序,我無法查看產生的源代碼,除非有人知道這樣做的方式 – earthling
我硬編碼一個網址到一個隨機圖像在線和解決。不知道爲什麼它不會顯示我的cdn中的圖像。 – earthling