Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Cache image in ViewCell, strange Aspect

$
0
0

Hi I have a problem without solution :(
I inserted images into the viewcell but they change their Aspect after the second time they are loaded.
The first time I see them like this

The second time I see them like this

The second time the aspect is set correctly thanks to the image cache.

Can you help me?
Ty

This is my code.

<ContentPage.Content>
    <StackLayout  VerticalOptions="Fill" BackgroundColor="Transparent" Padding="0,0,0,0">
        <Grid Padding="0,0,0,0" BackgroundColor="Transparent"  >
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <StackLayout Grid.Row="0" BackgroundColor="White">
                <SearchBar x:Name="searchBarAds" SearchButtonPressed="searchBarAds_ButtonPressed" />
            </StackLayout>

            <Grid Grid.Row="1" BackgroundColor="Transparent">
                <StackLayout>
                    <ListView x:Name="listViewAds" ItemsSource="{Binding LsAdsSource}" CachingStrategy ="RecycleElement" 
                              HasUnevenRows="True" MinimumHeightRequest="50" IsPullToRefreshEnabled="True" ItemTapped="OnItemSelected">
                        <ListView.ItemTemplate>
                            <DataTemplate>
                                <localTools:EventsViewCell />
                            </DataTemplate>
                        </ListView.ItemTemplate>
                    </ListView>
                </StackLayout>
            </Grid>
        </Grid>
    </StackLayout>
</ContentPage.Content>




 <ViewCell.View>
        <Grid Margin="10,0,10,0"  Padding="0,0,0,20" VerticalOptions="End"  >
            <Grid.RowDefinitions>
                <RowDefinition Height="AUTO" />
                <!--0-->
                <RowDefinition Height="AUTO" />
                <!--1-->
                <RowDefinition Height="AUTO" />
                <!--2-->
                <RowDefinition Height="AUTO" />
                <!--3-->
                <RowDefinition Height="AUTO" />
                <!--4-->
                <RowDefinition Height="AUTO" />
                <!--5-->
            </Grid.RowDefinitions>

            <!--0-->
            <StackLayout Grid.Row="0" Margin="0,0,0,0" >
                <Label            Text="{Binding Organization}" Style="{StaticResource labelTitle2}" 
                                                HorizontalTextAlignment="Start"  VerticalTextAlignment="Center" />
            </StackLayout>

            <!--1-->
            <StackLayout Grid.Row="1" >
                <Grid HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" >
                    <Image  VerticalOptions="Start"  Aspect="AspectFit"   >
                        <Image.Source>
                            <UriImageSource CachingEnabled="True" Uri="{Binding EVENT_IMAGE}" CacheValidity="10"  />
                        </Image.Source>
                    </Image>
                </Grid>
            </StackLayout>

            <!--2-->
            <StackLayout Grid.Row="2" Margin="0,0,0,0">
                <Label                  Text="{Binding Title}" Style="{StaticResource labelTitle3_Bold}" 
                                                HorizontalTextAlignment="Start"  VerticalTextAlignment="Center"  />
            </StackLayout>

            <!--3-->
            <StackLayout Grid.Row="3" Margin="0,0,0,0">
                <Label                  Text="{Binding Description}" Style="{StaticResource labelNormale1_Italic}" 
                                                HorizontalTextAlignment="Start"  VerticalTextAlignment="Center" />
            </StackLayout>
        .....
        .....

        </Grid>
    </ViewCell.View>

Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>