// Constructor public MainPage() { InitializeComponent(); // set up page's view model this.DefaultViewModel = new MainPageViewModel() { }; this.DataContext = this.DefaultViewModel; // handle callback from change to ViewModel ObservableCollection to synchronize with map pins this.DefaultViewModel.ApiViewModel = _tomTomApi.TomTomViewModel; _tomTomApi.TomTomViewModel.Results.CollectionChanged += Results_CollectionChanged; // tap into view model containing settings data _settingsViewModel = App.Current.Resources["SettingsViewModel"] as SettingsViewModel; // get reference to APIMonitor for handling progress bar state _apiMonitor = App.Current.Resources["ApiMonitor"] as APIMASH.ApiMonitor; // initialize map when page is done loading this.Loaded += Map_LoadedForFirstTime; }