mardi 24 mars 2020

How can I default checked a checkbox in WPF MVVM

I have an Employee Table. and I have an WPF Screen. in screen I want to have an "Exclude Former Employees" checkbox (checked as default) when it checked I generate report there is no Former Employee in table. but When I remove check in checkbox I want to see former employee.

See in my xaml:

<CheckBox Content="Exclude Former Employees" IsChecked="{Binding ExcludeFormerEmployees}" Margin="4" />

in ViewModel:

private bool _excludeFormerEmployees;
        public bool ExcludeFormerEmployees
        {
            get { return _excludeFormerEmployees; }
            set { Set(ref _excludeFormerEmployees, value); }
        }

In Generate Report Button Command (It's employee reports)

   if (_excludeFormerEmployees) hd.ExcludeFormerEmployees();

in Method:

 public void ExcludeFormerEmployees()
        { 
            RemoveAll(ef => Employee.IsDelegation==false&& Employee.Status==0);

        }

Thank you for all your helps.




Aucun commentaire:

Enregistrer un commentaire