Exemplo n.º 1
0
        private void textChangedHandler(Object sender, TextChangedEventArgs e)
        {
            String fromName = (((TextBox)sender).Name).ToString().ToUpper();
            float  fromValue;

            if (float.TryParse(((TextBox)sender).Text, out fromValue))
            {
                foreach (KeyValuePair <String, float> currency in currencies)
                {
                    String toName = currency.Key.ToString().ToUpper();
                    if (!fromName.Equals(toName))
                    {
                        TextBlock temp = (TextBlock)RootView.FindName("textBlockFrom" + fromName + "For" + toName);
                        temp.Text = currency.Key + " = " + (fromValue * ((float)currency.Value / (float)currencies[fromName])).ToString();
                    }
                }
            }
            else
            {
                foreach (KeyValuePair <String, float> currency in currencies)
                {
                    String toName = currency.Key.ToString().ToUpper();
                    if (!fromName.Equals(toName))
                    {
                        TextBlock temp = (TextBlock)RootView.FindName("textBlockFrom" + fromName + "For" + toName);
                        temp.Text = currency.Key + " = Invalid";
                    }
                }
            }
        }