public CalendarEventForm() { InitializeComponent(); var vm = new CalendarEventFormViewModel(); this.DataContext = vm; if (vm.CloseAction == null) { vm.CloseAction = new Action(() => this.Close()); } // FillComboBox(); }
public CalendarEventForm(IViewManager viewManager, ICalendarEventService calendarEventService, IUserService userService, IProjectService projectService)//You missed IUserService, which is used in your VM { InitializeComponent(); CalendarEventFormViewModel vm = (CalendarEventFormViewModel)this.DataContext; // this creates an instance of the ViewModel if (vm.CloseAction == null) { vm.CloseAction = new Action(() => this.Close()); } vm.ViewManager = viewManager; vm.CalendarEventService = calendarEventService; vm.UserService = userService; vm.ProjectService = projectService; }