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

MVVM how to call StopPullToRefreshLoading(true) from my ViewModel

5 Answers 89 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.
Rodney
Top achievements
Rank 1
Rodney asked on 11 Dec 2012, 11:01 PM
I'm using MVVM Light and I would like to get the Pull to Refresh "Loading" indicator to disappear when I retrieve data from my repository.  The example shows how to call the method StopPullToRefreshLoading(true) from code behind but I'd like to work without the code behind and maintain MVVM principles.  I'm new to MVVM so I'm aware this may be a trivial issue to solve.

Thank you,
Rodney

5 Answers, 1 is accepted

Sort by
0
Deyan
Telerik team
answered on 12 Dec 2012, 10:37 AM
Hello Rodney,

Thanks for writing.

Being a method, the StopPullToRefreshLoading cannot be called from a View Model in the usual MVVM approach. In similar scenarios it is okay to call the method without using MVVM architecture. Please note that MVVM is a convenient approach to organizing the structure of your application but when you need to call methods, it is okay to do so in the standard manner. Otherwise it is possible to use MVVM in this case as well by introducing a model with a corresponding property which, when changed, calls the method internally.

I hope this helps.

Kind regards,
Deyan
the Telerik team
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
0
Rodney
Top achievements
Rank 1
answered on 12 Dec 2012, 07:02 PM
I'll have to do further research to understand how to do what you describe.  Currently, my Model class only has data properties and no logic other than INPC.  Is there a preferred mechanism to get the code behind method to be called?  As of now, the only interaction between the view and the model I have is in data bindings.  Maybe a trigger of some sort that reacts to an INPC event.  Any pointers in the right direction would be appreciated.

Thank you,
Rodney
0
Deyan
Telerik team
answered on 15 Dec 2012, 12:08 PM
Hello Rodney,

You have many possible approaches for exploration. The simplest is to call the method in the code-behind file of the Page when the requested data arrives. We do this in our own projects.

Another approach would be to define a command that does it and trigger it when the data you have requested arrives.

As I do not know the architecture of your application, I cannot say for sure which approach you should use. Also note that MVVM is an approach that does not solve all problems in an elegant way and using it for everything might lead to over-engineered architecture. This, of course, is my personal opinion :-)

Let me know in case I can be of further help.

All the best,
Deyan
the Telerik team
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
0
Ismael
Top achievements
Rank 1
answered on 02 Apr 2013, 12:23 PM
I've created a behavior for this.

Basically, you can now bind to a IsLoading/IsSyncing property in your ViewModel that would be probably be tied to an async call. This way, when you signal that property to be "false" (end of the async request), the behavior will call on the StopPullToRefreshLoading() method automatically.
0
Victor
Telerik team
answered on 05 Apr 2013, 08:45 AM
Hi,

Another approach would be to inherit from RadDataboundListBox and add the necessary properties. This should be easy since you just need to encapsulate public methods.

Greetings,
Victor
the Telerik team
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
Tags
DataBoundListBox
Asked by
Rodney
Top achievements
Rank 1
Answers by
Deyan
Telerik team
Rodney
Top achievements
Rank 1
Ismael
Top achievements
Rank 1
Victor
Telerik team
Share this question
or