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

            if (NavigationContext.QueryString.ContainsKey("Action"))
            {
                this.Action = NavigationContext.QueryString["Action"];
            }
            else
            {
                this.Action = EditProfilePageActions.New;
            }

            if (NavigationContext.QueryString.ContainsKey("ProfileId"))
            {
                string profileIdStr = NavigationContext.QueryString["ProfileId"];
                int    profileId    = System.Int32.Parse(profileIdStr);
                if (App.VM.SelectedProfile == null || App.VM.SelectedProfile.Id != profileId)
                {
                    App.VM.SelectedProfile = (from Profile p in App.VM.Profiles where p.Id == profileId select p).FirstOrDefault();
                }
            }
            if (this.Action == EditProfilePageActions.Edit)
            {
                this.titleTextBlock.Text = "edit profile";
            }
            else
            {
                this.titleTextBlock.Text = "add profile";
                App.VM.SelectedProfile   = new Profile()
                {
                    Name = String.Empty, Gender = GenderId.Female, IsQuickProfile = false
                };
            }

            if (!e.IsNavigationInitiator && PhoneApplicationService.Current.State.ContainsKey("EditProfilePageState"))
            {
                this.PageState = (EditProfilePageState)PhoneApplicationService.Current.State["EditProfilePageState"];
                this.LoadFromState();
            }
            else
            {
                this.LoadFromSelectedProfile();
            }
        }
 public EditProfilePage()
 {
     InitializeComponent();
     this.PageState   = new EditProfilePageState();
     this.DataContext = App.VM;
 }