locked
[UWP] ListView lag RRS feed

  • Question

  • User348598 posted

    Xamarin.Forms 2.4.0.9102

    I have problem with ListView in UWP (only UWP). When I scrolling up or down then listview lag.

    My XAML:

    <ContentPage.Content> <ListView CachingStrategy="RecycleElement" ItemsSource="{Binding Products}" > <ListView.ItemTemplate> <DataTemplate> <ViewCell> <Label Grid.Row="0" Text="{Binding Name}" FontSize="Medium" TextColor="Black" /> </ViewCell> </DataTemplate> </ListView.ItemTemplate> </ListView> </ContentPage.Content>

    Details on screens.




    Wednesday, June 13, 2018 7:41 AM

All replies

  • User89714 posted

    @eternith - I find that UWP ListView performance on ARM mobile devices is appalling. On x64 desktops it isn't so bad. Whether that is just down to the power of the CPU I don't know. As Windows Mobile devices are pretty much defunct, I'm not overly concerned, but would still be interested in any performance improvements that can be applied.

    Note that the ListView CachingStrategy property on UWP is ignored, using RecycleElement even if RetainElement is specified - see https://bugzilla.xamarin.com/show_bug.cgi?id=44773#c5

    Wednesday, June 13, 2018 9:07 AM
  • User348598 posted

    @JohnHardman - but I do this on x64 (desktop) device :) Pay attension to attached images.

    Wednesday, June 13, 2018 9:31 AM
  • User89714 posted

    @eternith said: @JohnHardman - but I do this on x64 (desktop) device :) Pay attension to attached images.

    Have you profiled it to see where the time is used up?

    Wednesday, June 13, 2018 9:46 AM
  • User348598 posted

    ...::SOLVED::...

    This my solution for next generations :)

    Create ListView renderer for UWP:

    [assembly: ExportRenderer(typeof(NativeListView), typeof(MyProjects.UWP.Renderer.NativeUWPListViewRenderer))]
    namespace MyProjects.UWP.Renderer
    {
        public class NativeUWPListViewRenderer : ListViewRenderer
        {
            ListView listView;
    
            private ItemsPanelTemplate GetItemsPanelTemplate()
            {
                string xaml = "<ItemsPanelTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'> <VirtualizingStackPanel Orientation=\"Vertical\"/> </ItemsPanelTemplate>";
                return XamlReader.Load(xaml) as ItemsPanelTemplate;
            }
    
            protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.ListView> e)
            {
                base.OnElementChanged(e);
    
                listView = Control as ListView;
    
                if (e.NewElement != null)
                {
                    listView.ItemsPanel = GetItemsPanelTemplate();
                }
            }
        }
    }
    
    Thursday, June 14, 2018 5:03 AM
  • User244539 posted

    @eternith said: ...::SOLVED::...

    This my solution for next generations :)

    Create ListView renderer for UWP:

    [assembly: ExportRenderer(typeof(NativeListView), typeof(MyProjects.UWP.Renderer.NativeUWPListViewRenderer))]
    namespace MyProjects.UWP.Renderer
    {
        public class NativeUWPListViewRenderer : ListViewRenderer
        {
            ListView listView;
    
            private ItemsPanelTemplate GetItemsPanelTemplate()
            {
                string xaml = "<ItemsPanelTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'> <VirtualizingStackPanel Orientation=\"Vertical\"/> </ItemsPanelTemplate>";
                return XamlReader.Load(xaml) as ItemsPanelTemplate;
            }
    
            protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.ListView> e)
            {
                base.OnElementChanged(e);
    
                listView = Control as ListView;
    
                if (e.NewElement != null)
                {
                    listView.ItemsPanel = GetItemsPanelTemplate();
                }
            }
        }
    }
    

    Thank you very much!

    Wednesday, February 19, 2020 10:58 AM