Xamarin.Plugins icon indicating copy to clipboard operation
Xamarin.Plugins copied to clipboard

Locking app

Open ivanteles opened this issue 6 years ago • 7 comments

I'm using the icons in a list, but scrolling the list up and down the app is catching. I discovered this when I commented the icons and the app did not crash any more.

<ListView x:Name="list"
                  RefreshCommand="{Binding LoadMoreCommand}" IsRefreshing="{Binding IsLoading, Mode=OneWay}"
                  IsPullToRefreshEnabled="True"
                  HasUnevenRows="true"
                  SeparatorVisibility="Default" 
                  ItemsSource="{Binding Dados}" 
                  ItemSelected="ListView_OnItemSelected" SeparatorColor="{StaticResource DarkBackgroundColor}">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <StackLayout  Orientation="Vertical" VerticalOptions="Center" Padding="2">
                            <Frame BackgroundColor="White" HasShadow="false" OutlineColor="Transparent">
                                <StackLayout Orientation="Horizontal" HorizontalOptions="FillAndExpand" Margin="0">
                                    <Image Source="{Binding Foto}" WidthRequest="70" HeightRequest="95" Margin="5,0,0,0" />
                                    <StackLayout Orientation="Vertical" VerticalOptions="CenterAndExpand" HorizontalOptions="FillAndExpand" Padding="5,5,0,5" Spacing="0">
                                        <Label Text="{Binding Nome}" Margin="10,5,0,0" FontAttributes="Bold" FontSize="16" />
                                        <StackLayout Orientation="Horizontal" VerticalOptions="CenterAndExpand" HorizontalOptions="FillAndExpand" Padding="0" Spacing="0" Margin="5,5,0,0">
                                            <Label Text="{Binding Conceito}" Margin="10,5,0,0" TextColor="Silver" FontSize="14" />
                                            <StackLayout Orientation="Horizontal" HorizontalOptions="EndAndExpand" Padding="0" Spacing="0" Margin="0,5,0,0">
                                                <Label Text="{Binding Visualizacoes}" Margin="0,0,0,5" TextColor="Silver" FontSize="12" />
                                                <iconize:IconLabel Text="md-check-circle" TextColor="{StaticResource Azul}" FontSize="15" Margin="5,0,0,0" />
                                            </StackLayout>
                                        </StackLayout>
                                    </StackLayout>
                                    <StackLayout Orientation="Vertical" VerticalOptions="CenterAndExpand" Padding="0">
                                        <iconize:IconLabel Text="md-chevron-right" TextColor="{StaticResource Accent}" FontSize="40" />
                                    </StackLayout>
                                </StackLayout>
                            </Frame>
                        </StackLayout>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>

ivanteles avatar Jul 24 '17 18:07 ivanteles

My app on Android experienced the same issue. I changed the caching strategy to RecycleElement and there was no locking/slowdown.

The sample application uses the same caching strategy.

Xamarin.Plugins/Iconize/Samples/Iconize.FormsSample/Page1.xaml

Sample ListView

Not sure why the default strategy would cause an issue. In my application, I had a list of ~8 elements max. I used a datatemplate selector where only one item in the list had a IconButton. The slow down always occurred when the list item with the IconButton was off the screen and about to appear (via a scroll).

eamreyes avatar Jul 26 '17 19:07 eamreyes

@eamreyes thanks for the answer!

Where does this CachingStrategy = "RecycleElement" come from? Because in my listview it does not have this property!

ivanteles avatar Jul 26 '17 19:07 ivanteles

@ivanteles that property was added in a Xamarin.Forms release. See Caching Strategy. Or this blog.

My IDE's (R# + VS) intellisense indicates there is an error, but it is valid XAML.

image

eamreyes avatar Jul 27 '17 20:07 eamreyes

I am having this problem too. Using this nugget package on my android app crashes hard.

csampaio26 avatar Oct 20 '17 10:10 csampaio26

For me solved using iconbutton instead of iconlabel

ivanteles avatar Oct 20 '17 11:10 ivanteles

Its doesn't do much of a difference. Overall this plugin is very slow on android.

csampaio26 avatar Oct 20 '17 13:10 csampaio26

@eamreyes What version of Xamarin.Forms do you use? I think there are some changes from Xamarin.Forms to set ListView's CachingStrategy and I don't know from which version it is, but I'm using Xamarin.Forms 2.4.0.282 and the XAML code is looks like the following:

<ListView>
    <x:Arguments>
        <ListViewCachingStrategy>RecycleElement</ListViewCachingStrategy>
    </x:Arguments>
</ListView>

but if you want to set the CachingStrategy with code, you can derive from ListView control and use that derived control into XAML, like this:

public class CustomListView : ListView
{
    public CustomListView() : base(ListViewCachingStrategy.RecycleElement)
    {
    }
}

yunusefendi52 avatar Dec 20 '17 13:12 yunusefendi52