Bonjour,
Je travail actuellement sur l'implementation de l'API Flickr en UWP.
Je rencontre un soucis, je n'arrive pas a afficher mes images récupérers au format JSON et convertis en BitMapImage, côte-à-côte, j'ai essayé avec différentes
techniques comme les StackPanels, Canva, ListView mais rien a y faire j'essaye encore de trouver mais je en trouve pas quelque chose de convenable au niveau de l'affichage.
Auriez-vous une piste a me donner ?
Voici le code C#:
Voici le code XAML:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57 public sealed partial class MainPage : Page { private FlickrAuth flickr; public ObservableCollection<BitmapImage> ImgList = new ObservableCollection<BitmapImage>(); public MainPage() { InitializeComponent(); } private async void Flickr_Log_Click(object sender, RoutedEventArgs e) { flickr = new FlickrAuth(); string output; var FlickrUri = new Uri(await flickr.GetLonginLink()); var webAuthenticationResult = await WebAuthenticationBroker.AuthenticateAsync( WebAuthenticationOptions.None, FlickrUri, new Uri("http://www.example.com/")); if (webAuthenticationResult.ResponseStatus == WebAuthenticationStatus.Success) { output = webAuthenticationResult.ResponseData; await flickr.GetAccessToken(output); await flickr.FlickrOAuthRequest(); var res = await flickr.getPublicPhoto(); DownloadImageFlickr(res); } else if (webAuthenticationResult.ResponseStatus == WebAuthenticationStatus.ErrorHttp) { output = "HTTP Error returned by AuthenticateAsync() : " + webAuthenticationResult.ResponseErrorDetail; } else if (webAuthenticationResult.ResponseStatus == WebAuthenticationStatus.UserCancel) { output = "Authentication process was cancelled by the user"; } } private void DownloadImageFlickr(FlickrAuth.RootObject root) { if (root.stat == "ok") { int i = 0; foreach (var VARIABLE in root.photos.photo) { var photoUrl = "http://farm{0}.staticflickr.com/{1}/{2}_{3}_n.jpg"; var baseFlickrURL = string.Format(photoUrl, VARIABLE.farm, VARIABLE.server, VARIABLE.id, VARIABLE.secret); var bitmapImage = new BitmapImage(new Uri(baseFlickrURL)) {DecodePixelHeight = 100, DecodePixelWidth = 100}; ImgList.Add(bitmapImage); } } } private BitmapImage ImageSource { get; set; } }
Actuellement j'utilise une ListView mais il y a peut-être autre chose que vous pourriez me conseiller ^^
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 <Page x:Class="Epicture.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:Epicture" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Button x:Name="Flickr_Log" Content="Flickr" HorizontalAlignment="Left" Margin="80,48,0,0" VerticalAlignment="Top" Height="106" Width="291" Click="Flickr_Log_Click" /> <Button x:Name="Bouton_ImGur" Content="ImGur" HorizontalAlignment="Left" Margin="1288,48,0,0" VerticalAlignment="Top" Height="106" Width="329" /> <ListView ItemsSource="{x:Bind ImgList}" Margin="35,159,38,-159"> <ListView.ItemTemplate> <DataTemplate x:DataType="BitmapImage"> <StackPanel Orientation="Horizontal"> <Image Source="{x:Bind }"/> </StackPanel> </DataTemplate> </ListView.ItemTemplate> </ListView> </Grid> </Page>
Partager