45 Seitennavigation im View Model ausführen

Damit das Schreiben von Logik zur Seitennavigation im View Model durchgeführt werden kann, ist ein kleiner Dienst zu erstellen. Der Vorteil liegt darin, dass nun auch die Navigation über das Command Binding auf die View zur Verfügung gestellt werden kann. Die Logik wird somit zentral im View Model verfasst.

01 public static class AppNavigationService02 {03     private static PhoneApplicationFrame _rootFrame04         = (PhoneApplicationFrame)05            Application.Current.RootVisual;0607     public static void GoBack()08     {09         _rootFrame.GoBack();10     }1112     public static void NavigateTo(Uri targetUri)13     {14         _rootFrame.Navigate(targetUri);15     }16 }

Listing 45–1 Navigationservice ...

Get Windows Phone 8 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.