Xamarin Google驱动器图像

时间:2018-10-09 14:13:31

标签: xaml xamarin.forms google-api google-drive-api google-drive-realtime-api

我是xamarin的新手。我想在xaml视图中显示来自Google驱动器的图像。为此,我已经安装了Google.Apis.Drive.v3 nuget软件包。下面是我的代码。

C#代码

 **DriveService** driveService = new **DriveService**();
    var request = driveService.Files.List();
    request.Q = "mimeType='image/jpeg'";
    request.OauthToken = account.Properties["access_token"];
    request.Fields = "nextPageToken,files(id, name, thumbnailLink, webViewLink)";
    request.PageToken = pageToken;
    request.PageSize = 20;
    var result = request.Execute();
    var DrivePhotos = new ObservableCollection<object>(result.Files);

XAML代码

<StackLayout AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="0,0,1,1">
                <flv:FlowListView FlowColumnCount="3" RowHeight="100" SeparatorVisibility="Default"
                          HasUnevenRows="False" FlowItemsSource="{Binding DrivePhotos}" >
                    <flv:FlowListView.FlowColumnTemplate>
                        <DataTemplate>
                            <StackLayout Margin="3">
                                <!--<Image Source="{Binding thumbnailLink}" HeightRequest="100" WidthRequest="100" BackgroundColor="Aqua" />-->
                                <!--<Label Text="{Binding name}"></Label>-->

                                <ffimageloading:CachedImage HorizontalOptions="Center" VerticalOptions="Center" BackgroundColor="Accent" 
                                            WidthRequest="300" HeightRequest="300"
                                            DownsampleToViewSize="true"
                                            Source="{Binding thumbnailLink}">
                                </ffimageloading:CachedImage>


                            </StackLayout>
                        </DataTemplate>
                    </flv:FlowListView.FlowColumnTemplate>
                </flv:FlowListView>
            </StackLayout>

我在返回ID,名称,thumbnailLink,webViewLink中获得这些字段。

现在,我无法在xmal标签中显示thumbnailLink。我还使用DLToolkit.Forms.Controls.FlowListView来显示图像。

enter image description here

请帮助。

0 个答案:

没有答案