c# - Pull to Refresh executing the Command only once -
i've scoured internet simple solution none seemed have had same problem me.
so explain briefly, i'm using xamarin forms , have listview:
<listview x:name="kpilist" style="{staticresource customlist}" hasunevenrows="true" separatorvisibility="none" ispulltorefreshenabled="true" grid.row="1" grid.column="0" grid.columnspan="3"> </listview> i defined refreshcommand , isrefreshing properties this:
public partial class mainpage : contentpage { bool _isrefreshing = false; public bool isrefreshing { { return _isrefreshing; } set { _isrefreshing = value; onpropertychanged(nameof(isrefreshing)); } } public icommand refreshdata; public mainpage() { refreshdata = new command(repopulatelist); kpilist.refreshcommand = refreshdata; kpilist.isrefreshing = isrefreshing; { void repopulatelist() { isrefreshing = true; controller.kpis.clear(); foreach (kpiobj kpi in await webservices.getupdatedkpi(controller.savedkpiids)) { controller.kpis.add(kpi); } isrefreshing = false; } } the strange thing first time pull refresh works fine. second time try, never enters block of code command set to.
it if listview "loses" pointer command after first pull refresh.
to make work need change this:
kpilist.isrefreshing = isrefreshing; by
kpilist.setbinding(listview.isrefreshingproperty, nameof(isrefreshing)); in first 1 assigning value of isrefreshing of page property isrefreshing property of listview. changes omitted (as noticed).
note: if binding in xaml should work, need set bindingcontext in constructor of mainpage.
hope helps.-
Comments
Post a Comment