我想在flipview上显示“image_url”数据。但我有一个问题,那就是在flipview上只出现一个边框(图片没有出现)。
XAML:
<FlipView x:Name="listingImageFlipview" Grid.Row="1" Grid.RowSpan="3" Grid.Column="0" Margin="20,0,0,0" Width="230" Height="160" VerticalAlignment="Center" HorizontalAlignment="Left" BorderBrush="Black" BorderThickness="0.5" Background="{x:Null}">
<FlipView.ItemTemplate>
<DataTemplate>
<Grid x:Name="content" Margin="0,0,0,0">
<Border x:Name="coverBox" Width="230" Height="160">
<Border.Background>
<ImageBrush Stretch="Uniform" ImageSource="images/IP-placeholder.png"/>
</Border.Background>
<Image x:Name="cover" Source="{Binding ImageURL1}" HorizontalAlignment="Center" Stretch="UniformToFill" AutomationProperties.Name="{Binding ID}" ImageOpened="Image_ImageOpened" Loaded="cover_Loaded" Loading="cover_Loading"/>
</Border>
</Grid>
</DataTemplate>
</FlipView.ItemTemplate>
</FlipView>
代码:
try
{
string urlPath = "http://..../listings/" + listingIdDetail.Text + ".json?module=listings&page=1&token=3f63-dc43-c8d5-eb45-8cbf-b72d-9d98-800f";
var httpClient = new HttpClient(new HttpClientHandler());
var values = new List<KeyValuePair<string, string>>
{
};
HttpResponseMessage response = await httpClient.GetAsync(urlPath);
response.EnsureSuccessStatusCode();
if (!response.IsSuccessStatusCode)
{
listingDetailLoading.IsActive = false;
RequestException();
}
string jsonText = await response.Content.ReadAsStringAsync();
JsonObject jsonObject = JsonObject.Parse(jsonText);
JsonObject jsonData = jsonObject["data"].GetObject();
JsonObject groupObject1 = jsonData.GetObject();
JsonArray jsonGallery = groupObject1["gallery"].GetArray();
foreach (JsonValue groupValue1 in jsonGallery)
{
JsonObject groupObject3 = groupValue1.GetObject();
string imageUrl = groupObject3["image_url"].GetString();
ListingClass fileImage = new ListingClass();
fileImage.ImageURL1 = imageUrl;
BitmapImage bmi = new BitmapImage(new Uri(fileImage.ImageURL1));
Image image = new Image();
image.Source = bmi;
listingImageFlipview.Items.Add(image);
}
如何在flipview上显示图像?