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

Pull To Refresh And MVVM

6 Answers 103 Views
DataBoundListBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Lel12
Top achievements
Rank 1
Lel12 asked on 03 Jul 2014, 10:18 PM
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 !

6 Answers, 1 is accepted

Sort by
0
Accepted
Tsvyatko
Telerik team
answered on 08 Jul 2014, 11:54 AM
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.

 
0
Lel12
Top achievements
Rank 1
answered on 12 Jul 2014, 02:22 PM
Thank you for your sample which works really well ! But How can I call  StopPullToRefreshLoading(true)  in my ViewModel?
0
Rosy Topchiyska
Telerik team
answered on 16 Jul 2014, 06:06 PM
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.

 
0
Lel12
Top achievements
Rank 1
answered on 16 Jul 2014, 11:29 PM
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 !




0
Accepted
Rosy Topchiyska
Telerik team
answered on 21 Jul 2014, 08:19 PM
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.

 
0
Lel12
Top achievements
Rank 1
answered on 23 Jul 2014, 01:47 AM
Thank you it works like a charm ! 

Tags
DataBoundListBox
Asked by
Lel12
Top achievements
Rank 1
Answers by
Tsvyatko
Telerik team
Lel12
Top achievements
Rank 1
Rosy Topchiyska
Telerik team
Share this question
or