This is just another small but helpful tip for Windows Phone 7 developers. Imagine that you want your user to type in some input, that you need to proceed. One can handle the precessing by offering a “confirm”-Button or something like it or you can just react on the Enter-Key of the softkeyboard.which is presented, when a user clicks in a textbox.

So, how is this accomplished? The Textbox-Control does not provide a OnEnter-event, all one can be found is something called KeyDown-event. This event is what we will use for our need.

In the XAML of your appropriate TextBox you can add a method to the KeyDown which will be fired if a key enters the TextBoxControl.

I called mine OnEnter and you can easily check, which key of the softkeyboard was “entered” 🙂

It`s that simple 🙂

This blogpost is more like a little hint or tip, if you want to develop your application with the MVVM – design pattern. Within Windows Phone 7 apps you can easily navigate through PhoneApplicationPages in the code-behind of your views with the NavigationService – Class.

But what if you handle some logic/calculation within a ViewModel and you want to navigate to another View on the basis of the result, you cannot access the NavigationService in this static context.

The solution for this is very simple! All you have to do is the following:

  • In the appropiate ViewModel, just create a property of type NavigationService, like so



  • using the NavService like you do in code-behind

  • and don`t forget to set the Property in the code-behind of the approriate view, so that the NavService is valid and to avoid a NullReferenceException 🙂 You can do this in the constructor or any other initialization method.

I hope, that this little tip is useful for someone.