In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
In recent days, I have been loading and refreshing on the research. However, there are always so many tricks. In xamarin.forms, list comes with an attribute that doesn't pull up and load (didn't they think about what would happen when they encapsulated methods? (complain instead of complaining, the problem always has to be solved.
Since I don't have one, I'll write one myself.
Train of thought
Here's what I'm thinking.
What is pull-up refresh, that is to say, on the current page, when I see the last item, I need to load some new data, so can I write one, as soon as the last item appears, we will refresh the latest data?
1 public class InfiniteListView: ListView 2 {3 public static readonly BindableProperty LoadMoreCommandProperty = BindableProperty.Create (nameof (LoadMoreCommand), typeof (ICommand), typeof (InfiniteListView)); 4 public static readonly BindableProperty CanLoadMoreProperty = BindableProperty.Create (nameof (CanLoadMore), typeof (bool), typeof (InfiniteListView), true); 5 6 public ICommand LoadMoreCommand 7 {8 get {return (ICommand) GetValue (LoadMoreCommandProperty);} 9 set {SetValue (LoadMoreCommandProperty, value) } 10} 11 12 public bool CanLoadMore13 {14 get15 {16 return (bool) GetValue (CanLoadMoreProperty); 17} 18 set19 {20 SetValue (CanLoadMoreProperty, value) 21} 22} 23 24 public InfiniteListView () 25 {26 ItemAppearing + = InfiniteListView_ItemAppearing;27} 28 29 private void InfiniteListView_ItemAppearing (object sender, ItemVisibilityEventArgs e) 30 {31 if (! CanLoadMore) 32 {33 return;34} 35 var items = ItemsSource as IList 36 37 if (items! = null & & e.Item = = items [items.Count-1]) 38 {39 if (LoadMoreCommand! = null & & LoadMoreCommand.CanExecute (null)) 40 LoadMoreCommand.Execute (null); 41} 42} 43}
Let's inherit listview to implement its ItemAppearing method, and then determine again and again whether there is the last item in the method (to be honest, I don't know if this is good for the program, but now I just want to implement it), and execute the binding method as soon as the last item appears.
In page binding, you need to
So . . Is it really very simple?
After a brief test, a problem was found. That is, my list data, there are grouping, there may be multiple list in a list, so isn't the last item always the outermost data? I changed the method simply.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.