private void TextBox_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { if (LocationTextBox.Text.Length == 0) { LocationTextBox.BorderBrush = Brushes.Red; } else { try { LocationTextBox.BorderBrush = Brushes.Transparent; Response = APIWrapper.GetData(LocationTextBox.Text + ", US"); SetFormControls(Response.List[0]); SetDayView(); } catch (System.Net.WebException) { LocationTextBox.BorderBrush = Brushes.Red; } } } }
public MainWindow() { InitializeComponent(); Response = APIWrapper.GetData("Huntsville, AL"); SetFormControls(Response.List[0]); SetDayView(); WeatherIcon.Source = new BitmapImage( new Uri("Media/" + CurrentHour.Weather[0].Icon.Substring(0, 2) + ".png", UriKind.Relative)); DataContext = this; }