This is a migrated thread and some comments may be shown as answers.

ListView PullToRefesh RelayCommand Binding

2 Answers 19 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Priom
Top achievements
Rank 1
Priom asked on 08 Jan 2016, 06:09 PM

I have the following code in my viewModel:

1.<p>public RelayCommand RefreshPage { get; private set; }</p><p>public MainViewModel(INavigationService navigationService)<br>        {<br>            _navigationService = navigationService;<br>            LoadData();           <br>            GetDetailsCommand = new RelayCommand<object>(ShowDetailsAction);           <br>            RefreshPage = new RelayCommand(() => RefreshPageAction());<br>        }</p><p>private async System.Threading.Tasks.Task<object> LoadData()<br>        {<br>            BusyIndicatorVisibility = true;<br>            try<br>            {<br>                await _NewsItemCollection.GetAllNewsItem((x) =><br>                {<br>                    AllNewsItem = x;<br>                    BusyIndicatorVisibility = false;<br>                });<br>            }<br>            catch<br>            {<br>                //NetworkNotFoundErrorVisible = true;<br>            }<br>            return null;<br>        }</p><p> private async System.Threading.Tasks.Task<object> RefreshPageAction()<br>        {<br>            //BusyIndicatorVisibility = true;<br>            return await LoadData();<br>        }</p>
I want to bind the the RefreshPage RelayCommand to the PullToRefresh Behavior of ListView. How can i do that?

 

2 Answers, 1 is accepted

Sort by
0
Priom
Top achievements
Rank 1
answered on 08 Jan 2016, 06:12 PM

public RelayCommand RefreshPage { get; private set; }

 public MainViewModel(INavigationService navigationService)
        {
            _navigationService = navigationService;

            LoadData();

            RefreshPage = new RelayCommand(() => RefreshPageAction());
        }

 

private async System.Threading.Tasks.Task<object> LoadData()
        {
            BusyIndicatorVisibility = true;
            try
            {
                await _NewsItemCollection.GetAllNewsItem((x) =>
                {
                    AllNewsItem = x;
                    BusyIndicatorVisibility = false;
                });
            }
            catch
            {
                //NetworkNotFoundErrorVisible = true;
            }
            return null;
        }

private async System.Threading.Tasks.Task<object> RefreshPageAction()
        {
            //BusyIndicatorVisibility = true;
            return await LoadData();
        }

Sorry for the code in previous thread. Please refer to this code snippet. Thanks in advance

0
Tsvyatko
Telerik team
answered on 13 Jan 2016, 03:49 PM
Hello Priom,

Currently, you cannot bind the command directly to ListView when items is refreshing. You can use the API with events and properties as described here - http://docs.telerik.com/windows-universal/controls/radlistview/features/listview-pulltorefresh and create attached behavior (similar to event to command approach) to trigger command when needed.

 I have logged feature request to expose command property so that this scenario can be supported directly.

Regards,
Tsvyatko
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
ListView
Asked by
Priom
Top achievements
Rank 1
Answers by
Priom
Top achievements
Rank 1
Tsvyatko
Telerik team
Share this question
or