public ResultsPage()
        {
            this.InitializeComponent();

            this.navigationHelper = new NavigationHelper(this);
            this.navigationHelper.LoadState += this.NavigationHelper_LoadState;
            this.navigationHelper.SaveState += this.NavigationHelper_SaveState;

            this.DataContext = HomePage.CalculatedModel;
        }
        public HomePage()
        {
            this.InitializeComponent();
            this.navigationHelper = new NavigationHelper(this);
            this.navigationHelper.LoadState += navigationHelper_LoadState;
            this.navigationHelper.SaveState += navigationHelper_SaveState;

            // MVVM is not used in this example. We're porting an existing sample from Silverlight MVC
            // we will make use of the existing pattern to achieve the results
            model = new DietCalculatorModel();
            controller = new DietCalculatorController(model);

            // bydefault Male is Selected, hence collapse hips
            txtHips.Visibility = tblHips.Visibility = Visibility.Collapsed;

            cmbGender.SelectionChanged += (sender, args) =>
            {
                var isSelectedItemMale = ((string)cmbGender.SelectedItem == "Male");
                txtHips.Visibility = tblHips.Visibility = isSelectedItemMale ? Visibility.Collapsed : Visibility.Visible;

                // corner case: reset hipsText to empty if the user had typed in hips and later changed the gender
                if (isSelectedItemMale) txtHips.Text = string.Empty;
            };

            // subscribe to IdealBMI and IdealWeight changed events on the model to update the UI
            // as per the implementation in the core project,
            // any change in IdealBMI or IdealWeight are notified using appropriate event handlers
            model.IdealBMIChanged += (sender, e) =>
            {
                txtIdealBMI.Text = e.IdealBMI.ToString();
            };

            model.IdealWeightChanged += (sender, e) =>
            {
                txtIdealWeight.Text = e.IdealWeight.ToString();
            };

            txtIdealWeight.TextChanged += (sender, e) =>
            {
                controller.SetWeight(StringToNumberUtility.GetDouble(txtWeight.Text, 0.00));
                controller.SetHeight(StringToNumberUtility.GetDouble(txtHeight.Text, 0.00));
                controller.SetIdealWeight(StringToNumberUtility.GetDouble(txtIdealWeight.Text, 0.00));

            };
            txtIdealBMI.TextChanged += (sender, e) =>
            {
                controller.SetWeight(StringToNumberUtility.GetDouble(txtWeight.Text, 0.00));
                controller.SetHeight(StringToNumberUtility.GetDouble(txtHeight.Text, 0.00));
                controller.SetIdealBMI(StringToNumberUtility.GetDouble(txtIdealBMI.Text, 0.00));
            };
        }