Как я могу связать изображения с шириной и высотой 300x300 от images[1]
до xaml?Как привязать Список <image> к xaml?
public class TrackSpotify
{
public class ExternalUrls
{
public string spotify { get; set; }
}
public class Image
{
public int height { get; set; }
public string url { get; set; }
public int width { get; set; }
}
public class Item
{
public string album_type { get; set; }
public List<string> available_markets { get; set; }
public ExternalUrls external_urls { get; set; }
public string href { get; set; }
public string id { get; set; }
public List<Image> images { get; set; }
public string name { get; set; }
public string type { get; set; }
public string uri { get; set; }
}
public class Albums
{
public string href { get; set; }
public List<Item> items { get; set; }
public int limit { get; set; }
public string next { get; set; }
public int offset { get; set; }
public object previous { get; set; }
public int total { get; set; }
}
public class RootObject
{
public Albums albums { get; set; }
}
}
"images" : [ {
"height" : 640,
"url" : "i.scdn.co/image/8642802d13a53541e313781c34521a0d33099aac",
"width" : 640
}, {
"height" : 300,
"url" : "..................",
"width" : 300
}, {
"height" : 64,
"url" : "....................",
"width" : 64
} ],
<Grid.RowDefinitions>
<RowDefinition Height="200"></RowDefinition>
<RowDefinition Height="140"></RowDefinition>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0">
<Image Source="{Binding url}"></Image>
</StackPanel>
<Grid Grid.Row="1">
<StackPanel VerticalAlignment="Top" Margin="10">
<TextBlock Text="{Binding name}" Foreground="#D4D4D4" FontSize="12"></TextBlock>
<TextBlock Text="{Binding album_type}" Foreground="#404040" FontSize="15" FontWeight="SemiBold"></TextBlock>
</StackPanel>
</Grid>
</Grid>
</DataTemplate>
var arrays = JsonConvert.DeserializeObject<NewReleaseSpotify.RootObject>(query);
spotifyItems.ItemsSource = arrays.albums.items;
Где произносится 'spotifyItems'? (Используется в последней строке кода). Вы можете попытаться использовать 'ItemsControl' для отображения списка изображений. –
Какая у вас проблема? С вашего единственного предложения немного сложно сказать. – Sheridan
каждый 'Item' в' arrays.albums.items' может иметь несколько изображений ('List'), поэтому вы можете заменить один элемент управления «Image» на свой XAML на «ListBox» или что-то в этом роде. В любом случае, чтобы вы начали, попробуйте отобразить только первое изображение: '' –
har07