public IMainViewModel Build(Action <string> errorCallback, Size initialSize = null)
        {
            // Register Global ViewModelVariables

            var firstDispayedDate = TimeTools.Today();          // TODO find last open

            gridSizeVariable = new SharedState <Size>(initialSize ?? new Size(new Width(400), new Height(400)));
            var selectedDateVariable = new SharedState <Date>(firstDispayedDate);
            var selectedMedicalPracticeIdVariable = new SharedState <Guid>(Guid.Empty);
            var roomFilterVariable = new SharedState <Guid?>();
            var appointmentModificationsVariable = new SharedState <AppointmentModifications>();

            var selectedPatientForAppointmentSearchVariable = new SharedState <Patient>();


            // Create ViewModelCollection

            viewModelCommunication.CreateViewModelCollection <ITherapyPlaceRowViewModel, TherapyPlaceRowIdentifier>(
                Constants.ViewModelCollections.TherapyPlaceRowViewModelCollection
                );

            viewModelCommunication.CreateViewModelCollection <IAppointmentGridViewModel, AggregateIdentifier>(
                Constants.ViewModelCollections.AppointmentGridViewModelCollection
                );

            viewModelCommunication.CreateViewModelCollection <ITimeGridViewModel, AggregateIdentifier>(
                Constants.ViewModelCollections.TimeGridViewModelCollection
                );

            viewModelCommunication.CreateViewModelCollection <IAppointmentViewModel, Guid>(
                Constants.ViewModelCollections.AppointmentViewModelCollection
                );

            // build factorys

            var appointmentModificationsBuilder = new AppointmentModificationsBuilder(medicalPracticeRepository,
                                                                                      readModelRepository,
                                                                                      viewModelCommunication,
                                                                                      selectedDateVariable,
                                                                                      gridSizeVariable);

            var appointmentViewModelBuilder = new AppointmentViewModelBuilder(viewModelCommunication,
                                                                              labelRepository,
                                                                              commandService,
                                                                              appointmentModificationsVariable,
                                                                              selectedDateVariable,
                                                                              adornerControl,
                                                                              appointmentModificationsBuilder);

            var therapyPlaceRowViewModelBuilder = new TherapyPlaceRowViewModelBuilder(viewModelCommunication,
                                                                                      medicalPracticeRepository,
                                                                                      therapyPlaceTypeRepository,
                                                                                      adornerControl,
                                                                                      appointmentModificationsVariable,
                                                                                      gridSizeVariable);

            var appointmentGridViewModelBuilder = new AppointmentGridViewModelBuilder(medicalPracticeRepository,
                                                                                      readModelRepository,
                                                                                      viewModelCommunication,
                                                                                      gridSizeVariable,
                                                                                      roomFilterVariable,
                                                                                      selectedMedicalPracticeIdVariable,
                                                                                      appointmentModificationsVariable,
                                                                                      appointmentViewModelBuilder,
                                                                                      therapyPlaceRowViewModelBuilder);

            var addAppointmentDialogWindowBuilder = new AddAppointmentDialogWindowBuilder(patientRepository,
                                                                                          readModelRepository,
                                                                                          medicalPracticeRepository,
                                                                                          labelRepository,
                                                                                          selectedMedicalPracticeIdVariable,
                                                                                          selectedDateVariable,
                                                                                          appointmentViewModelBuilder,
                                                                                          errorCallback);

            var printDialogWindowBuilder = new PrintDialogWindowBuilder(medicalPracticeRepository,
                                                                        readModelRepository,
                                                                        errorCallback);

            // build stand-alone viewModelMessageHandler

            confirmChangesMessageHandler = new ConfirmChangesMessageHandler(viewModelCommunication,
                                                                            commandService,
                                                                            appointmentModificationsVariable,
                                                                            errorCallback);

            rejectChangesMessageHandler = new RejectChangesMessageHandler(viewModelCommunication,
                                                                          appointmentModificationsVariable);


            // build factories



            // create permanent ViewModels

            var dateDisplayViewModel = new DateDisplayViewModel(selectedDateVariable);

            var medicalPracticeSelectorViewModel = new MedicalPracticeSelectorViewModel(session,
                                                                                        medicalPracticeRepository,
                                                                                        localSettingsRepository,
                                                                                        selectedMedicalPracticeIdVariable,
                                                                                        appointmentModificationsVariable,
                                                                                        errorCallback);

            var roomSelectorViewModel = new RoomFilterViewModel(medicalPracticeRepository,
                                                                roomFilterVariable,
                                                                selectedDateVariable,
                                                                selectedMedicalPracticeIdVariable,
                                                                appointmentModificationsVariable,
                                                                errorCallback);

            var dateSelectorViewModel = new DateSelectorViewModel(selectedDateVariable);

            var gridContainerViewModel = new GridContainerViewModel(viewModelCommunication,
                                                                    medicalPracticeRepository,
                                                                    selectedDateVariable,
                                                                    selectedMedicalPracticeIdVariable,
                                                                    gridSizeVariable,
                                                                    new List <AggregateIdentifier>(),
                                                                    50,
                                                                    appointmentGridViewModelBuilder,
                                                                    errorCallback);

            var undoRedoViewModel = new UndoRedoViewModel(viewModelCommunication,
                                                          appointmentModificationsVariable,
                                                          session,
                                                          errorCallback);

            var overviewPageViewModel = new OverviewPageViewModel(viewModelCommunication,
                                                                  dateDisplayViewModel,
                                                                  medicalPracticeSelectorViewModel,
                                                                  roomSelectorViewModel,
                                                                  dateSelectorViewModel,
                                                                  gridContainerViewModel,
                                                                  undoRedoViewModel,
                                                                  addAppointmentDialogWindowBuilder,
                                                                  printDialogWindowBuilder,
                                                                  appointmentModificationsVariable,
                                                                  selectedMedicalPracticeIdVariable,
                                                                  selectedDateVariable,
                                                                  medicalPracticeRepository,
                                                                  errorCallback);

            var patientSelectorViewModel = new PatientSelectorViewModel(patientRepository,
                                                                        selectedPatientForAppointmentSearchVariable,
                                                                        errorCallback);

            var searchPageViewModel = new SearchPageViewModel(patientSelectorViewModel,
                                                              selectedPatientForAppointmentSearchVariable,
                                                              selectedDateVariable,
                                                              viewModelCommunication,
                                                              commandService,
                                                              readModelRepository,
                                                              medicalPracticeRepository,
                                                              errorCallback);

            var optionsPageViewModel = new OptionsPageViewModel();

            var mainViewModel = new ViewModels.MainView.MainViewModel(viewModelCommunication,
                                                                      overviewPageViewModel,
                                                                      searchPageViewModel,
                                                                      optionsPageViewModel,
                                                                      appointmentModificationsVariable);

            viewModelCommunication.RegisterViewModelMessageHandler <AsureDayIsLoaded>(gridContainerViewModel);
            viewModelCommunication.RegisterViewModelMessageHandler <ShowPage>(mainViewModel);
            viewModelCommunication.RegisterViewModelMessageHandler(confirmChangesMessageHandler);
            viewModelCommunication.RegisterViewModelMessageHandler(rejectChangesMessageHandler);

            return(mainViewModel);
        }