コード例 #1
0
        public VacationListItemPartViewModel(VacationListItemViewModel owner, VacationService.Vacation vacation)
        {
            if (owner == null)
                throw new ArgumentNullException(nameof(owner));
            if (vacation == null)
                throw new ArgumentNullException(nameof(vacation));

            Owner = owner;
            Vacation = vacation;

            Owner.Owner.PropertyChanged += (_, e) => 
            {
                if (e.PropertyName == nameof(VacationsViewModel.CanManageVacations))
                {
                    RaisePropertyChanged(() => CanManage);
                    UpdateCommands();
                }
            };

            Owner.Owner.Staffing.PropertyChanged += (_, e) =>
            {
                if (e.PropertyName == nameof(Staffing.StaffingViewModel.Current))
                { 
                    RaisePropertyChanged(() => CanManage);
                    UpdateCommands();
                }
            };
        }
コード例 #2
0
        public VacationListItemPartViewModel(VacationListItemViewModel owner, VacationService.Vacation vacation)
        {
            if (owner == null)
                throw new ArgumentNullException(nameof(owner));
            if (vacation == null)
                throw new ArgumentNullException(nameof(vacation));

            Owner = owner;
            Vacation = vacation;

            Owner.Owner.PropertyChanged += (_, e) => 
            {
                if (e.PropertyName == nameof(VacationsViewModel.CanManageVacations))
                    UpdateCommands();
            };

            Owner.Owner.Staffing.PropertyChanged += (_, e) =>
            {
                if (e.PropertyName == nameof(Staffing.StaffingViewModel.Current))
                    UpdateCommands();
            };

            Vacation.PropertyChanged += (_, e) =>
            {
                if (e.PropertyName == nameof(Vacation.Agreements))
                    UpdateCommands();
            };

            timer = new System.Timers.Timer(1000);
            timer.Elapsed += (_, __) => Owner.Owner.RunUnderDispatcher(new Action(() => UpdateCommands()));
            timer.Start();
        }