Navigation in mvvm - mvvm

I am trying to navigate on a frame with pages but instead of giving views to the page I am giving view models.
This works fine, but the problem is when I navigate between the pages the status of the radio buttons for example doesn't stay the same. It stays only if I use the views and not the view models.
Any ideas?
Thanks.

Some code to explain how you navigate between each control would allow us to give you more specific answers, currently we can only guess what you are doing.
It sounds like you are creating a new instance of each ViewModel when you are navigating between pages. This of course means things such as radio buttons and control states will not remain consistent.
You could use a framework such as MVVM Light and make use of their ViewModelLocator pattern. This means you could have one static instance of each ViewModel.
You could also store all of these states in a simple data model, and then simply have your new ViewModel instance refer to this model and update it's check boxes etc appropriately.

Related

What is the best method to implement MVVM in Flutter

I'm trying to make a simple App to stretch my legs and implement MVVM using Flutter which I have never done.
On the main page of the App, I'm displaying items from a collection fetched from the backend. So my logic would be that when the page appears, the MainPageViewModel is initialized and the area that should display the collection should show a loader. During the initialization, the call to the back end is made. Once this call resolves, I would store the result in a variable and somehow notify the View that it can update its visuals, either to display an error or the collection that's been fetched. It's especially that notifying the view that it should update that stomps me. I'm also guessing it'd be good practice to not render the view until the viewModel has finished initializing.
I'm curious how you reckon this should be made. I know I could just dump it into a FutureBuilder but my goal here is to learn the MVVM concepts to start doing more complex stuff.
Thanks in advance!

Positioning ListViews in WinJS Metro apps using scrollIntoView

I am building a jscript-based Windows 8 Metro app. The main screen of this application is a scrolling "panorama" view with several list views showing various aspects of the app's state. In some cases the user will select something on the page which results in a navigation to another page (using the WinJS.Navigation.navigate method.
When the user hits the back arrow on the other page, it returns to the main screen, and I use "scrollIntoView" on to position the screen to the section that the user was working on before the navigation occurred.
Unfortunately this hardly ever results in correctly positioning the view. It seems random. I suspect that the page isn't finished being built yet and that the scroll values are set based on the state at some snapshot in time.
Now the question:
Is there some what to be notified by WinJS ListView objects that they are completely rendered and layed out? Or is this the job of the page's ready function?
Thanks for any insight!
Putting multiple list views side by side is Not A Good Idea(TM). I would recommend putting one list view, and placing your content in a grouped data source to get the groups. If the items have different templates, then you can use a custom item Template selector to dynamically select a template.
Additionally, to ensure that the list view is scrolled to the right position, you need to use the indexOfFirstVisible to set the items the name suggests.

Implementing Tab Control Pages Ribbon Tab using MVVM

I am creating an Application which will be a Tab based application having separate pages for each Tab. I want use RibbonTab as the Tab.
On selecting one RibbonTab corresponding UserControl will be loaded in the below section.
Each RibbonTab and each UserControl should behave like a pair.
First Challenge - It would be easy to use single ViewModel for each RibbonTab-UserControl pair. But how to share single ViewwModel in to separate view.
Second Challenge - What is best way to implement this application
One Ribbontab and One UserControl is already ready. Waiting for how to associate those two.
I'm not clear on the First challenge could you elaborate it please and I'll edit the answer.
As for the second challenge I highly recomend choosing a framework as that will make implementing MVVM a little easier Framework Comparison
I use a ContentControl and ResourceDictionary to determine what view to display based on the bound ViewModel as in this example. That technique could be used for the tab control as well here are a couple links on how to implement this:
Microsoft Tab Controled application Tutorial
Tab Control Binding

Programmatically select menu item for mvvm prism application using Telerik RadMenu

Hello I have a prism/mvvm style application and am using the RadMenu control. I also have a view/view model pair in one project and another view/view model pair for my RadMenu control in another project. Basically I would like to use the event aggregator to send an event to the view model for the RadMenu (the view model that is paired with the view that the RadMenu sits inside of). So that the RadMenu's view model can notify the RadMenu to switch to a different RadMenuItem programmatically. I think I can use a blend behavior to contain the behavior I'm looking to reproduce, but I cannot find a method in the RadMenu that will allow me to programmatically select a specific menu item.
If the control does not support this now, is there a work around? Thanks.
I believe this is a missunderstanding. As far as I know there is no selection on the RadMenu. You can only Check or Uncheck Items in your Menus. Are you trying to emulate a user clicking on a specific item just to trigger the functionality behind the menu-item? If that's the case I would propose another way and directly handle the EA-Message in the ViewModel. You can trigger the code from there then. If you're doing MVVM the logic behind the menu-items is implented in your VM anyways. :)

GWT Activity - Places => DialogBox?

I'm trying to use the GWT Activity & Place model, but I'm having some
troubles with it about how to use my activities.
I've got a LoginActivity which drives the user to another activity :
DemandsActivity.
My DemandsActivity manages a view ("DemandsView") which displays a
simple list of demands (with a CellTable).
The whole works fine.
I would like to be able to show the details of a demand, from a
selected line of my cellTable, by displaying
a DialogBox with the informations.
I thought I could use one more
activity to do that : DemandDetailsActivity.
But I don't know how to do that.
Or I've been wrong from the beginning. Maybe should I put several presenters (displays) into my activity ? One presenter to display my CellTable, and another one to display a selected element of my CellTable in a DialogBox, without changing Place ?
What do you think of that ?
Thanks
What you are trying to do is called master-detail view. People have been implementing it with GWT, just google around.
On a side note: in MVP parlance Activities are presenters and Views are displays, so when you say put several presenters (displays) into my activity it really makes no sense.
Presenters should correspond to a place and handle business logic. They should not be concerned with the display part. And they should be testable, which means they should run on desktop/server JRE without GWT client dependencies.
So, all the GUI building part should be inside Views. And, yes, you could have multiple Views per Activity if this makes sense. BUt, personally, I'd go with one View that shows details (possibly dialog) when Activity instructs it to.
You should normally have a one to one relationship between Places and Activities but you may have many Views per a given Activity. In the project I'm currently working on we create an interface per Presenter and its associated View and then have our Activities implement any Presenters for the Views it needs to display.