protected void updateScreen()
        {
            // Reload user data from database, since the list of registered events have changed.
            this._loggedInUser = model.DomainModels.StudentModel.getByMatricId(this._loggedInUser.MatricId);

            List<model.Event> upcomingEvents = model.DomainModels.EventModel.getAll();
            this._upcomingEventsList = new ObservableCollection<EventItem>();
            foreach ( model.Event e in upcomingEvents )
            {
                bool isRegistered = false;

                foreach (model.Event r in this._loggedInUser.RegisteredEvents)
                    if (r.Id == e.Id) isRegistered = true;

                this._upcomingEventsList.Add(new EventItem(e, (e.Owner.MatricId == this._loggedInUser.MatricId), isRegistered));
            }
            this.upcomingEventsListGrid.ItemsSource = this._upcomingEventsList;

            // Load events based on logged in user (created events for now, registered events in the future).
            this._createdEventsList = model.DomainModels.EventModel.getByOwner(_loggedInUser.MatricId);
            this.createdEventsListGrid.ItemsSource = this._createdEventsList;

            this.registeredEventsListGrid.ItemsSource = this._loggedInUser.RegisteredEvents;
        }
        private void NavigationService_LoadCompleted(object sender, NavigationEventArgs e)
        {
            this.NavigationService.LoadCompleted -= NavigationService_LoadCompleted;

            NavigationData navData = (NavigationData)e.ExtraData;
            if (navData == null || navData.loggedInUser == null)
            {
                this.NavigationService.Navigate(new Uri("LoginScreen.xaml", UriKind.Relative));
            }
            else
            {
                this._loggedInUser = this._loggedInUser = model.DomainModels.StudentModel.getByMatricId(navData.loggedInUser.MatricId);
                this.loggedInUserLabel.Content = this._loggedInUser.Name;
                this.updateScreen();
            }

            if (navData.statusCode != NavigationData.STATUS_NONE)
            {
                if (navData.statusCode == NavigationData.STATUS_NOTICE)
                {
                    this.statusMessage.Style = (Style)this.FindResource("StatusMessageNoticeStyle");
                }
                else if (navData.statusCode == NavigationData.STATUS_ERROR)
                {
                    this.statusMessage.Style = (Style)this.FindResource("StatusMessageErrorStyle");
                }

                this.statusMessage.Content = navData.statusMessage;
                Storyboard sb = (Storyboard)this.FindResource("StatusMessageFadeIn");
                this.statusMessage.BeginStoryboard(sb);
            }
        }
        private void NavigationService_LoadCompleted(object sender, NavigationEventArgs e)
        {
            this.NavigationService.LoadCompleted -= NavigationService_LoadCompleted;

            NavigationData navData = (NavigationData)e.ExtraData;
            if (navData != null)
            {
                if (navData.loggedInUser == null)
                {
                    this.NavigationService.Navigate(new Uri("LoginScreen.xaml", UriKind.Relative));
                }
                else
                {
                    this._loggedInUser = navData.loggedInUser;
                    this.loggedInUserLabel.Content = this._loggedInUser.Name;
                }

                // If eventID from navData exists, it means that we need to edit the event!
                if (navData.eventID != -1)
                {
                    this.Title = "Edit Event";

                    // Load event data from database and its data will bind onto the form.
                    this._curEvent = model.DomainModels.EventModel.getByID(navData.eventID);
                }
            }
        }