private void WeeklyGrid_Unloaded(object sender, RoutedEventArgs e)
 {
     // Clear the data context so we don't receive view model updates while we are not visible
     ViewModel = null;
 }
        private void WeeklyGrid_Loaded(object sender, RoutedEventArgs e)
        {
            // Check if we have a proper data context set
            MainViewModel model = DataContext as MainViewModel;
            if (model != null)
            {
                ViewModel = model;
            }

            // Call Update() to set up view based on events
            Update();
        }