protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (NavigationContext.QueryString.ContainsKey("id"))
            {
                string idQueryString = NavigationContext.QueryString["id"];
                int id = 0;
                if (!Int32.TryParse(idQueryString, out id))
                {
                    throw new ArgumentException("id is not valid value!");
                }

                ToDoItemDetailsViewModel viewModel = new ToDoItemDetailsViewModel(new ToDoItemRepository());
                this.DataContext = viewModel;
                string currentUri = e.Uri.OriginalString;
                viewModel.OnToDoItemChanged += new GeomindMe.ViewModels.ToDoItemDetailsViewModel.LocationEventHandler(
                        (geoLocation) =>
                        {
                            Dispatcher.BeginInvoke(new Action(() =>
                            {
                                NavigateMap(new GeoCoordinate(geoLocation.Latitude, geoLocation.Longitude), true);
                            }));
                        });
                viewModel.Load(id, currentUri);

                return;
            }
            else
            {
                throw new ArgumentNullException("id must not be null!");
            }
        }
Ejemplo n.º 2
0
 private static ToDoItemDetailsViewModel GetNewToDoItemDetailsViewModel()
 {
     ToDoItemDetailsViewModel toDoItemDetailsViewModel = null;
     if (DesignerProperties.IsInDesignTool)
     {
         toDoItemDetailsViewModel = new ToDoItemDetailsViewModel(new DesignToDoItemRepository(), 5);
     }
     else
     {
         toDoItemDetailsViewModel = new ToDoItemDetailsViewModel(new ToDoItemRepository());
     }
     return toDoItemDetailsViewModel;
 }
Ejemplo n.º 3
0
 public static void CreateToDoItemDetailsViewModel()
 {
     ToDoItemDetailsViewModel toDoItemDetailsViewModel = GetNewToDoItemDetailsViewModel();
     _toDoItemDetailsViewModel = toDoItemDetailsViewModel;
 }
Ejemplo n.º 4
0
        public void LoadToDoItemDetailsViewModelFromApplicationState()
        {
            if (!PhoneApplicationService.Current.State.ContainsKey(ToDoItemDetailsViewModelPropertyName))
            {
                return;
            }

            var viewModel = PhoneApplicationService.Current.State[ToDoItemDetailsViewModelPropertyName] as ToDoItemDetailsViewModel;
            if (viewModel == null)
            {
                return;
            }

            ViewModelLocator._toDoItemDetailsViewModel = viewModel;
        }
Ejemplo n.º 5
0
 public static void ClearToDoItemDetailsViewModel()
 {
     _toDoItemDetailsViewModel.Cleanup();
     _toDoItemDetailsViewModel = null;
 }