From: gu.martinm@gmail.com Date: Sun, 17 Aug 2014 09:11:11 +0000 (+0200) Subject: WeatherInformation WP8: trying to get ready for IoC X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=e600abbcfa345606fbfadf122ad8e676ca20a17b;p=CSharpForFun%2F.git WeatherInformation WP8: trying to get ready for IoC --- 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; }