From e600abbcfa345606fbfadf122ad8e676ca20a17b Mon Sep 17 00:00:00 2001 From: "gu.martinm@gmail.com" Date: Sun, 17 Aug 2014 11:11:11 +0200 Subject: [PATCH] WeatherInformation WP8: trying to get ready for IoC --- WindowsPhone/WeatherInformation/WeatherInformation/MainPage.xaml.cs | 2 +- .../WeatherInformation/WeatherInformation/SelectedDatePage.xaml.cs | 2 +- .../WeatherInformation/ViewModels/MainViewModel.cs | 4 ++-- .../WeatherInformation/ViewModels/SelectedDateViewModel.cs | 6 +++++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/WindowsPhone/WeatherInformation/WeatherInformation/MainPage.xaml.cs b/WindowsPhone/WeatherInformation/WeatherInformation/MainPage.xaml.cs index 428b1f2..26b6878 100644 --- a/WindowsPhone/WeatherInformation/WeatherInformation/MainPage.xaml.cs +++ b/WindowsPhone/WeatherInformation/WeatherInformation/MainPage.xaml.cs @@ -46,7 +46,7 @@ namespace WeatherInformation { if (_mainViewModel == null) { - _mainViewModel = new MainViewModel(); + _mainViewModel = new MainViewModel(new SettingsViewModel()); } DataContext = _mainViewModel; diff --git a/WindowsPhone/WeatherInformation/WeatherInformation/SelectedDatePage.xaml.cs b/WindowsPhone/WeatherInformation/WeatherInformation/SelectedDatePage.xaml.cs index 4706982..cdf906c 100644 --- a/WindowsPhone/WeatherInformation/WeatherInformation/SelectedDatePage.xaml.cs +++ b/WindowsPhone/WeatherInformation/WeatherInformation/SelectedDatePage.xaml.cs @@ -31,7 +31,7 @@ namespace WeatherInformation { if (_selectedDateViewModel == null) { - _selectedDateViewModel = new SelectedDateViewModel(); + _selectedDateViewModel = new SelectedDateViewModel(new SettingsViewModel()); } DataContext = _selectedDateViewModel; diff --git a/WindowsPhone/WeatherInformation/WeatherInformation/ViewModels/MainViewModel.cs b/WindowsPhone/WeatherInformation/WeatherInformation/ViewModels/MainViewModel.cs index bca102b..951a59e 100644 --- a/WindowsPhone/WeatherInformation/WeatherInformation/ViewModels/MainViewModel.cs +++ b/WindowsPhone/WeatherInformation/WeatherInformation/ViewModels/MainViewModel.cs @@ -13,13 +13,13 @@ namespace WeatherInformation.ViewModels { private readonly SettingsViewModel _settings; - public MainViewModel() + public MainViewModel(SettingsViewModel settings) { this.ForecastItems = new ObservableCollection(); this.CurrentItems = new ObservableCollection(); // Get the _settings for this application. - _settings = new SettingsViewModel(); + _settings = settings; } /// diff --git a/WindowsPhone/WeatherInformation/WeatherInformation/ViewModels/SelectedDateViewModel.cs b/WindowsPhone/WeatherInformation/WeatherInformation/ViewModels/SelectedDateViewModel.cs index 06cecf9..5510bd7 100644 --- a/WindowsPhone/WeatherInformation/WeatherInformation/ViewModels/SelectedDateViewModel.cs +++ b/WindowsPhone/WeatherInformation/WeatherInformation/ViewModels/SelectedDateViewModel.cs @@ -15,8 +15,12 @@ namespace WeatherInformation.ViewModels { public class SelectedDateViewModel : INotifyPropertyChanged { - private readonly SettingsViewModel _settings = new SettingsViewModel(); + private readonly SettingsViewModel _settings; + public SelectedDateViewModel(SettingsViewModel settings) + { + _settings = settings; + } public String TitleTextCityCountry { get; private set; } -- 2.1.4