Ejemplo n.º 1
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            var vm   = new TodoItemViewModel();
            var task = default(TodoItem);

            if (e.NavigationMode == System.Windows.Navigation.NavigationMode.New)
            {
                if (NavigationContext.QueryString.ContainsKey("id"))
                {
                    var id = int.Parse(NavigationContext.QueryString["id"]);
                    if (id > 0)
                    {
                        task = (App.Current as WinPhoneTodo.App).TodoMgr.GetTask(id);
                    }
                }

                if (task != null)
                {
                    vm.Update(task);
                }
            }
            else     // use default
            {
                vm.Update(task);
            }
            DataContext = vm;
        }
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            var vm = new TodoItemViewModel();
            var task = default(TodoItem);

            if (e.NavigationMode == System.Windows.Navigation.NavigationMode.New)
            {
                if (NavigationContext.QueryString.ContainsKey("id"))
                {
                    var id = int.Parse(NavigationContext.QueryString["id"]);
                    if (id > 0)
                        task = (App.Current as WinPhoneTodo.App).TodoMgr.GetTask(id);
                }

                if (task != null)
                {
                    vm.Update(task);
                }
            } else { // use default
                vm.Update(task);
            }
            DataContext = vm;
        }