public void Cells_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            SpreadsheetCell spreadsheetCell = sender as SpreadsheetCell; //Sender as a spreadsheet cell

            switch (e.PropertyName)                                      //switch on the property changed
            {
            case ("Text"):                                               //if text has been changed
                if (spreadsheetCell.Text == string.Empty)
                {
                    spreadsheetCell.Value = string.Empty;
                    NotifyCellPropertyChanged(spreadsheetCell);
                    //spreadsheetCell.Sendupdate();
                }

                else if (spreadsheetCell.Text[0] == '=')
                {
                    spreadsheetCell.Value = spreadsheetCell.Text;
                    NotifyCellPropertyChanged(spreadsheetCell);
                    spreadsheetCell.Sendupdate();
                }
                else if (spreadsheetCell.Text[0] != '=' && spreadsheetCell.Value == string.Empty)
                {
                    spreadsheetCell.Value = spreadsheetCell.Text;
                    NotifyCellPropertyChanged(spreadsheetCell);
                    spreadsheetCell.Sendupdate();
                }
                else if (spreadsheetCell.Text[0] != '=' && spreadsheetCell.Value[0] != '=')
                {
                    spreadsheetCell.Value = spreadsheetCell.Text;
                    NotifyCellPropertyChanged(spreadsheetCell);
                    spreadsheetCell.Sendupdate();
                }

                break;

            case ("Value"):
                try
                {
                    if (spreadsheetCell.Value != string.Empty)
                    {
                        if (spreadsheetCell.Value[0] == '=')
                        {
                            if (char.IsLetter(spreadsheetCell.Value[1]) && spreadsheetCell.Value.Length <= 4 && spreadsheetCell.Value.Length >= 2)
                            {
                                string          varcol         = spreadsheetCell.Value[1].ToString();
                                string          varrow         = spreadsheetCell.Value.Substring(2);
                                SpreadsheetCell referencedcell = getcellat(varcol, varrow);
                                if (spreadsheetCell.Text != referencedcell.Text)
                                {
                                    spreadsheetCell.Text = referencedcell.Text;
                                }
                                referencedcell.Referencesme(spreadsheetCell);
                            }
                            else if (spreadsheetCell.Value.Length >= 2)     //starts with = and is within the length of a valid function
                            {
                                ExpTree expTree = new ExpTree(spreadsheetCell.Value.Substring(1));
                                expTree.Eval();
                                string varcol;
                                string varrow;
                                double vardata;
                                Dictionary <string, double> vardic = new Dictionary <string, double>(expTree.variables);
                                foreach (string key in vardic.Keys)
                                {
                                    varcol = key.Substring(0, 1);
                                    varrow = key.Substring(1);
                                    SpreadsheetCell referencedcell = getcellat(varcol, varrow);
                                    if (referencedcell == spreadsheetCell)
                                    {
                                        //ToDo-- If self is in the equation
                                        vardata = 0;
                                    }
                                    else
                                    {
                                        Double.TryParse(referencedcell.Text, out vardata);
                                    }

                                    referencedcell.Referencesme(spreadsheetCell);
                                    expTree.SetVAr(key, vardata);
                                }
                                string eval = expTree.Eval().ToString();
                                if (spreadsheetCell.Text != eval)
                                {
                                    spreadsheetCell.Text = eval;
                                }
                            }
                        }
                    }
                }
                catch
                {
                    spreadsheetCell.Text = "#ERROR";
                }
                break;
            }
        }