Events What is supported + Navigation?

Feb 11, 2013 at 11:28 PM
Hi

I am wondering what events are supported? As far as I can tell button click events are supported but I am wondering about other events.

I am also wondering about navigation. I see in the samples there is a navigation sample but wondering if there is a tutorial to follow along with.
Coordinator
Feb 12, 2013 at 3:34 PM
I generally advocate use of blend-style event triggers, in combination with CallMethodAction, to wire up methods in a ViewModel with events in a View. There's no restriction in terms of what events to handle, but the method called cannot have any parameters. That's usually not a problem because most of the time properties of elements are bound to ViewModel properties which can be read from within the method. See this blog post for more info.

On the other hand, for navigation I generally use commands with parameters. You can see an example of that in the navigation sample. For the tutorial, you can simply follow steps outlined in the project ReadMe file. Notice how I'm binding the Source property of the navigation Frame to the SelectedPage property on the ViewModel. Let me know what you think, and good luck!

Tony
Feb 13, 2013 at 10:55 PM
tonysneed wrote:
I generally advocate use of blend-style event triggers, in combination with CallMethodAction, to wire up methods in a ViewModel with events in a View. There's no restriction in terms of what events to handle, but the method called cannot have any parameters. That's usually not a problem because most of the time properties of elements are bound to ViewModel properties which can be read from within the method. See this blog post for more info.

On the other hand, for navigation I generally use commands with parameters. You can see an example of that in the navigation sample. For the tutorial, you can simply follow steps outlined in the project ReadMe file. Notice how I'm binding the Source property of the navigation Frame to the SelectedPage property on the ViewModel. Let me know what you think, and good luck!

Tony
Ok I will check it out. I am sure I will have more questions about it all. I want to use blend so hopefully they got some options to show me these "event triggers" you speak off.
Feb 15, 2013 at 5:31 PM
Edited Feb 15, 2013 at 6:58 PM
Hey

I was thinking how do you do events like these

1) OnNavigatedTo/From
2) On Load


Edit

I am looking at the Navigator Sample and step 1 looks sort of out of date.
  1. Create a MockNavigator that Implements System.Windows.Controls.INavigate
    • Just return true in the Navigate method
  // STEP: Create a MockNavigator that Implements System.Windows.Controls.INavigate
    public class MockNavigator : INavigator
    {
        public void NavigateTo(string pageName)
        {
            Debug.WriteLine("Navigating to " + pageName);
        }
    }
Feb 16, 2013 at 1:27 AM
Edited Feb 16, 2013 at 1:37 AM
Hey,

So after much playing around I think I figured it out the navigation(other questions still stand)

An outstanding question though. How do you pass parameters along?

Here is a tutorial I made while learning how to do it. Please check it over and let me know if I did anything wrong

Tutorial
Coordinator
Feb 16, 2013 at 5:35 PM
Ah, so you're talking about navigation for a Windows Phone app! There is special support built-in for this scenario, and you'll find an example in the Samples folder after installing the 3.1 version of the toolkit for VS 2010: SimpleMvvm-WindowsPhoneNav. It includes a ReadMe file with instructions.

Tony
Feb 16, 2013 at 6:22 PM
tonysneed wrote:
Ah, so you're talking about navigation for a Windows Phone app! There is special support built-in for this scenario, and you'll find an example in the Samples folder after installing the 3.1 version of the toolkit for VS 2010: SimpleMvvm-WindowsPhoneNav. It includes a ReadMe file with instructions.

Tony
Yes. I been looking at it. That is what the tutorial I wrote is based on. However some of the stuff was out of date in that sample file and it does not answer my questions


1) OnNavigatedTo/From
2) On Load

How do you do the above events using the MVVM pattern

3) How do you pass parameters along what you can do with navigation?
Coordinator
Feb 16, 2013 at 6:32 PM
Feb 18, 2013 at 5:28 PM
tonysneed wrote:
See this discussion thread: http://simplemvvmtoolkit.codeplex.com/discussions/267069.
Hey. I am not sure if this is what I am really after. I am after query parameters right now. Would you know how to those. I know light MVVM can do it. Hoping that SimpleMVVM can do it to.

If you can help me through it that would be great. I will then add it to my tutorial that I wrote.

Then after that I am still not sure about

1) OnNavigatedTo/From
2) On Load

and the MVVM way.
Feb 24, 2013 at 10:05 PM
It would be great if you could right a tutorial or help me through it(and I will add it to my tutorial).
Coordinator
Feb 25, 2013 at 2:03 AM
I don't have time to work up a tutorial right now, other than the sample project. But if you look at my last comment on that thread, you'll see the NavigationHelper class, which is actually part of the toolkit assembly. That class has a static queue that you can use to hold page values passed to pages when navigating. You'll also find a link to a zip file with a sample project. Sorry I can't do more, but that should give you something to go on.