MVVM how to call StopPullToRefreshLoading(true) from my ViewModel

6 posts, 0 answers
  1. Rodney
    Rodney avatar
    2 posts
    Member since:
    Jan 2012

    Posted 11 Dec 2012 Link to this post

    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
  2. Deyan
    Admin
    Deyan avatar
    2039 posts

    Posted 12 Dec 2012 Link to this post

    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.
  3. DevCraft banner
  4. Rodney
    Rodney avatar
    2 posts
    Member since:
    Jan 2012

    Posted 12 Dec 2012 Link to this post

    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
  5. Deyan
    Admin
    Deyan avatar
    2039 posts

    Posted 15 Dec 2012 Link to this post

    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.
  6. Ismael
    Ismael avatar
    3 posts
    Member since:
    Mar 2013

    Posted 02 Apr 2013 Link to this post

    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.
  7. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 05 Apr 2013 Link to this post

    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.
Back to Top
DevCraft banner