protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { base.OnNavigatedTo(e); if (e.NavigationMode == System.Windows.Navigation.NavigationMode.New) { var vm = new SpeakerDetailsViewModel(); var speaker = default(Speaker); if (NavigationContext.QueryString.ContainsKey("id")) { var id = int.Parse(NavigationContext.QueryString["id"]); speaker = SpeakerManager.GetSpeaker(id); } else if (NavigationContext.QueryString.ContainsKey("key")) { var key = NavigationContext.QueryString["key"]; speaker = SpeakerManager.GetSpeakerWithKey(key); } if (speaker != null) { vm.Update(speaker); } DataContext = vm; } }