WeatherInformation WP8: trying to get ready for IoC
authorgu.martinm@gmail.com <gu.martinm@gmail.com>
Sun, 17 Aug 2014 09:11:11 +0000 (11:11 +0200)
committergu.martinm@gmail.com <gu.martinm@gmail.com>
Sun, 17 Aug 2014 09:11:11 +0000 (11:11 +0200)
WindowsPhone/WeatherInformation/WeatherInformation/MainPage.xaml.cs
WindowsPhone/WeatherInformation/WeatherInformation/SelectedDatePage.xaml.cs
WindowsPhone/WeatherInformation/WeatherInformation/ViewModels/MainViewModel.cs
WindowsPhone/WeatherInformation/WeatherInformation/ViewModels/SelectedDateViewModel.cs

index 428b1f2..26b6878 100644 (file)
@@ -46,7 +46,7 @@ namespace WeatherInformation
             {
                 if (_mainViewModel == null)
                 {
-                    _mainViewModel = new MainViewModel();
+                    _mainViewModel = new MainViewModel(new SettingsViewModel());
                 }
 
                 DataContext = _mainViewModel;
index 4706982..cdf906c 100644 (file)
@@ -31,7 +31,7 @@ namespace WeatherInformation
             {
                 if (_selectedDateViewModel == null)
                 {
-                    _selectedDateViewModel = new SelectedDateViewModel();
+                    _selectedDateViewModel = new SelectedDateViewModel(new SettingsViewModel());
                 }
 
                 DataContext = _selectedDateViewModel;
index bca102b..951a59e 100644 (file)
@@ -13,13 +13,13 @@ namespace WeatherInformation.ViewModels
     {
         private readonly SettingsViewModel _settings;
 
-        public MainViewModel()
+        public MainViewModel(SettingsViewModel settings)
         {
             this.ForecastItems = new ObservableCollection<ItemViewModel>();
             this.CurrentItems = new ObservableCollection<ItemViewModel>();
 
             // Get the _settings for this application.
-            _settings = new SettingsViewModel();
+            _settings = settings;
         }
 
         /// <summary>
index 06cecf9..5510bd7 100644 (file)
@@ -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; }