ListView PullToRefesh RelayCommand Binding

3 posts, 0 answers
  1. Priom
    Priom avatar
    12 posts
    Member since:
    Jan 2014

    Posted 08 Jan Link to this post

    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. Priom
    Priom avatar
    12 posts
    Member since:
    Jan 2014

    Posted 08 Jan in reply to Priom Link to this post

    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

  3. DevCraft banner
  4. Tsvyatko
    Admin
    Tsvyatko avatar
    833 posts

    Posted 13 Jan Link to this post

    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
Back to Top