title: C# UWP OpenWeatherAPI using mvvm
body: <p>I'm trying to build a simple application in UWP that shows the current weather for my location.</p>
  
  <p>I'm verry new to this. The problem is that I dont know where I should call the OpenWeatherAPI. Is it in the ViewModel? How do I show for example Temperature (Temp) from the CurrentWeatherForecast in my MainPage.xaml (my view) using ViewModel?</p>
  
  <p>MainPage.XAML</p>
  
  <pre><code>`xmlns:weatherVM="using:UWPMM.ViewModels"
  Loaded="Window_Loaded"
  Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"&gt;
      &lt;Page.DataContext&gt;
          &lt;weatherVM:WeatherViewModel&gt;
          &lt;/weatherVM:WeatherViewModel&gt;
      &lt;/Page.DataContext&gt;
  &lt;Grid&gt;
  &lt;Stackpanel&gt;
  &lt;TextBlock Text="{Binding Temp}"&gt;&lt;/TextBlock&gt;`
  </code></pre>
  
  <p>Model named CurrentWeatherForecast. Here I also have patsted JSON as class from OpenWeatherMaps response.</p>
  
  <pre><code>    public async Task&lt;RootObject&gt; GetCurrentWeather(string lat, string lon)
      {
          var http = new HttpClient();
          var uri = String.Format(OpenWeatherUrl + "weather?lat=" + lat + "&amp;lon=" + lon + "&amp;units=metric&amp;appid=" + OpenWeatherApiKey + "&amp;mode=json");
          var response = await http.GetAsync(uri);
          var result = await response.Content.ReadAsStringAsync();
          var data = JsonConvert.DeserializeObject&lt;RootObject&gt;(result);
  
          return data;
      }
  </code></pre>
  
  <p>MainPage.XAML.cs</p>
  
  <pre><code>    private void Window_Loaded(object sender, RoutedEventArgs e)
      {
          GetCurrentPosition();
      }
      private async void GetCurrentPosition()
      {
          CurrentWeatherForecast currentWeatherForecast = new 
          CurrentWeatherForecast();
  
          var position = await LocationManager.GetPosition();
          string lat = position.Coordinate.Latitude.ToString();
          string lon = position.Coordinate.Longitude.ToString();
          await currentWeatherForecast.GetCurrentWeather(lat, lon);
       }
  </code></pre>
  
  <p>ViewModel named WeatherViewModel (Edited)</p>
  
  <pre><code>public class WeatherViewModel : ViewModelBase
  {
  
      CurrentWeatherForecast currentWeather;
  
      public WeatherViewModel()
      {
          currentWeather = new CurrentWeatherForecast();
      }
      private string _temp;
      public string Temp
      {
          get
          {
              return _temp;
          }
          set
          {
              _temp = value;
              OnPropertyChanged();
          }
      }
   }
  </code></pre>