带有ffimageloading的Listview在导航离开页面并返回后会加载缩小的图像

时间:2019-07-22 22:05:55

标签: xamarin xamarin.forms

在Xamarin Forms应用程序中,我有一个Syncfusion SfListView,其项目模板包含ffimageloading图像控件。列表视图有一个项目点击事件,可导航到详细信息页面。导航回去后,我将列表重新绑定到页面的onappearing方法中。有时,在大多数情况下(并非始终),当您单击列表项,导航到详细信息页面并返回时,列表将加载您单击的项目,但会加载您单击的行中的图像缩小了。我附了一张照片。这是相关代码

    <syncfusion:SfListView x:Name="CountriesListView" ItemTapped="SflistView_ItemTapped"
                 AutoFitMode="Height"  ItemsSource="{ Binding CountryList }" VerticalOptions="FillAndExpand">
        <syncfusion:SfListView.HeaderTemplate>
            <DataTemplate>
              ......
            </DataTemplate>
        </syncfusion:SfListView.HeaderTemplate>
        <syncfusion:SfListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>
                    <Frame OutlineColor="Gray" Padding="2"  HasShadow="True" HeightRequest="200">
                        <Grid RowSpacing="5" ColumnSpacing="0" Margin="10,5">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*" />
                                <RowDefinition Height="AUTO" />
                            </Grid.RowDefinitions>

                            <!--<Image Source="{Binding MainIMageURL}" Aspect="Fill" Grid.RowSpan="2">
                                            </Image>-->
                            <ffimageloading:CachedImage Aspect="Fill" Grid.RowSpan="2"
                                                FadeAnimationEnabled="true"
                                                Source="{ Binding MainIMageURL }" />
                            <Image Source="{Binding ShadowOverlay}" Grid.RowSpan="2"  Aspect="Fill" VerticalOptions="End" HorizontalOptions="Fill" />

                            <Grid Margin="10,10,10,0" RowSpacing="10" ColumnSpacing="10" Grid.Row="1">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="AUTO" />
                                    <!--<RowDefinition Height="25" />-->
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="25" />
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="AUTO" />
                                </Grid.ColumnDefinitions>

                                <Label Text="{Binding Name}"  Grid.Row="0" Grid.ColumnSpan="3" HorizontalOptions="Center"
                                   VerticalOptions="End"
                                   FontSize="25" LineBreakMode="NoWrap" TextColor="#FFFFFF">
                                    <Label.FontFamily>
                                        <OnPlatform x:TypeArguments="x:String">
                                            <On Platform="iOS" Value="HelveticaNeue-Bold" />
                                            <On Platform="Android" Value="sans-serif-medium" />
                                        </OnPlatform>
                                    </Label.FontFamily>
                                </Label>
                            </Grid>
                        </Grid>
                    </Frame>
                </ViewCell>
            </DataTemplate>
        </syncfusion:SfListView.ItemTemplate>
    </syncfusion:SfListView>


    protected override void OnAppearing()
    {
        BindData();
    }

    private async Task BindData()
    {
        await LoadCountries();
    }

    private async Task LoadCountries()
    {
        try
        {
            CountriesListView.IsBusy = true;
            Console.WriteLine("Getting countries");

            await vm.RefreshDataAsync();

            Console.WriteLine("Countries retrieved");


        }
        catch (Exception ex)
        {
                 .......
        }
        finally
        {
            CountriesListView.IsBusy = false;
        }
    }

enter image description here

0 个答案:

没有答案