Need an advice regarding BackStage and MVVM

3 posts, 1 answers
  1. Eyal
    Eyal avatar
    5 posts
    Member since:
    Jul 2012

    Posted 12 Dec 2011 Link to this post

    Hi,

    I'm rather new to Telerik WPF controls (and WPF as a whole) and currently having a blast with them (awesome job guys).
    While developing a WPF application for my company I encountered a small problem, not directly related to the controls themselves, but rather to the MVVM model and the way it works with the BackStage.

    Basically, what I am building is an application that behaves similar to office tools, with BackStage that shows recent files created by the user. 
    From the BackStage menu the user can open, edit etc these files. The files are opened on top of the main window, meaning that the main window always stays open (kinda like outlook and new mail items).

    The application is using MvvmLight model/toolkit.

    My problem is that, if the user creates a new file or edit a file, I have no way to reflect that in the "recent files" section of the BackStage - as the main window always stays in the background and the "recent files" section was bind to an object in the main window view model.

    I guess that I can use some sort of a static collection, application scope, but it doesn't seem like a good practice.
    What I was hoping is for some ideas on how to tackle that issue without breaking the MVVM model if possible.
    Any idea would be greatly appreciated.

    Cheers.
  2. Answer
    Miro Miroslavov
    Admin
    Miro Miroslavov avatar
    588 posts

    Posted 15 Dec 2011 Link to this post

    Hi Eyal,

     You can use a feature of the MvvmLight called Messages. If your MainViewModel has a property RecentItems then you can listen for a message saying "Added to recent items" and respond to it with actually adding the item to the RecentItems collection. And also the message could be send by other ViewModel - for example DocuementViewModel.
    You can my blog post about that, including an example project with messages.
    Hope it helps.

    Best wishes,
    Miro Miroslavov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Eyal
    Eyal avatar
    5 posts
    Member since:
    Jul 2012

    Posted 15 Dec 2011 Link to this post

    Thanks, that exactly what I needed
Back to Top