コード例 #1
0
ファイル: MainPage.xaml.cs プロジェクト: Aaron-Williams/Testy
        private void btnNew_Click(object sender, RoutedEventArgs e)
        {
            NewEmployee cw = new NewEmployee();
            EmployeeDataForm employeeDataForm = new EmployeeDataForm();
            employeeDataForm.Margin = new Thickness(3);
            employeeDataForm.Width = 450;
            employeeDataForm.TheEmployee = new Employee();
            employeeDataForm.IsLocked = false;

            cw.LayoutRoot.Children.Add(employeeDataForm);
            cw.HasCloseButton = false;
            cw.Title = "New Employee Details";
            cw.Closed += (s, args) =>
            {
                if (cw.DialogResult.Value && employeeDataForm.IsValid)
                {
                    EmployeesManager em = this.Resources["employeeManagerViewSource"] as EmployeesManager;
                    em.Employees.Add(employeeDataForm.TheEmployee);
                }
            };
            cw.Closing += (s, args) =>
            {
                if (!employeeDataForm.IsValid && cw.DialogResult.Value)
                {
                    MessageBox.Show("Some of field values are not valid.\nPlease fix all 					marked fielsd and try agan");
                    args.Cancel = true;
                }
            };
            cw.Show();
        }
コード例 #2
0
        private void btnNew_Click(object sender, RoutedEventArgs e)
        {
            NewEmployee      cw = new NewEmployee();
            EmployeeDataForm employeeDataForm = new EmployeeDataForm();

            employeeDataForm.Margin      = new Thickness(3);
            employeeDataForm.Width       = 450;
            employeeDataForm.TheEmployee = new Employee();
            employeeDataForm.IsLocked    = false;

            cw.LayoutRoot.Children.Add(employeeDataForm);
            cw.HasCloseButton = false;
            cw.Title          = "New Employee Details";
            cw.Closed        += (s, args) =>
            {
                if (cw.DialogResult.Value && employeeDataForm.IsValid)
                {
                    EmployeesManager em = this.Resources["employeeManagerViewSource"] as EmployeesManager;
                    em.Employees.Add(employeeDataForm.TheEmployee);
                }
            };
            cw.Closing += (s, args) =>
            {
                if (!employeeDataForm.IsValid && cw.DialogResult.Value)
                {
                    MessageBox.Show("Some of field values are not valid.\nPlease fix all 					marked fielsd and try agan");
                    args.Cancel = true;
                }
            };
            cw.Show();
        }