Pull To Refresh And MVVM

7 posts, 2 answers
  1. Lel12
    Lel12 avatar
    7 posts
    Member since:
    Sep 2013

    Posted 03 Jul 2014 Link to this post

    Hello, 

    is it possible to bind the Pull To Refresh Beahviour to a command in  the ViewModel ? If so how should I proceed, do you have any  examples or samples that show how to do it ?

    Thank You !
  2. Answer
    Tsvyatko
    Admin
    Tsvyatko avatar
    833 posts

    Posted 08 Jul 2014 Link to this post

    Hello Amine,

    I have prepared sample demonstrating one way to implement MVVM with RadDataBoundListBox. Have a look at the project attached and let us know if this helps.

    Regards,
    Tsvyatko
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. DevCraft banner
  4. Lel12
    Lel12 avatar
    7 posts
    Member since:
    Sep 2013

    Posted 12 Jul 2014 in reply to Tsvyatko Link to this post

    Thank you for your sample which works really well ! But How can I call  StopPullToRefreshLoading(true)  in my ViewModel?
  5. Rosy Topchiyska
    Admin
    Rosy Topchiyska avatar
    551 posts

    Posted 16 Jul 2014 Link to this post

    Hi Amine,

    I am not completely sure what is your scenario. Could you please elaborate a bit more on when you wish to call the StopPullToRefreshLoading method?

    I look forward to your reply.

    Regards,
    Rosy Topchiyska
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  6. Lel12
    Lel12 avatar
    7 posts
    Member since:
    Sep 2013

    Posted 16 Jul 2014 in reply to Rosy Topchiyska Link to this post

    Hello,

    For Example I Have this Delegate  that I initialize in my construor : 

      refreshCommand = new DelegateCommand((s) =>
                {
                    Update();
                });
    Where Update() is a REST request with Hammock :

    public void Update()
    {
    [.....]
     restClient.BeginRequest(restRequest, UpdatecallBack);
    }
    After my CallBack function finishes, the little animation that shows that the ListBox is Loading is still Spinning even after my function finished loading the data. How can I make the indicator stop spinning ?

    Thank you !




  7. Answer
    Rosy Topchiyska
    Admin
    Rosy Topchiyska avatar
    551 posts

    Posted 21 Jul 2014 Link to this post

    Hello Amine,

    Here is a modification in the context of the sample project we have sent you. You can try to keep the action parameter of the command in a field of the view model class and in the UpdateCallback(..) method you can try to execute the action:
    public class MainViewModel
    {
        private Action callbackAction;
     
        public MainViewModel()
        {
            ...
     
            this.Command = new DelegateCommand(async (s) =>
            {
                this.callbackAction = (Action)s;
                this.Update();
            });
        }
     
        private void UpdateCallback(RestRequest request, RestResponse response, object userState)
        {
            //update the Data collection
     
            if (this.callbackAction != null)
            {
                this.callbackAction();
            }
        }
    ...
    }

    Let us know if this works for you.

    Regards,
    Rosy Topchiyska
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  8. Lel12
    Lel12 avatar
    7 posts
    Member since:
    Sep 2013

    Posted 22 Jul 2014 in reply to Rosy Topchiyska Link to this post

    Thank you it works like a charm ! 

Back to Top
DevCraft banner