// Custom constructor to pass Employee object public CompDetails(object data) : this() { // Bind context to Employee this.DataContext = data; BonusInput.DataContext = this; if (data is Employee) { emp = (Employee)data; string name1 = ""; string value1 = ""; string name2 = ""; string value2 = ""; emp.SpareDetailProp1(ref name1, ref value1); emp.SpareDetailProp2(ref name2, ref value2); SpareProp1Name.Content = name1; SpareProp1Value.Content = value1; SpareProp2Name.Content = name2; SpareProp2Value.Content = value2; if (!(emp is Manager)) { emp.SpareDetailProp2(ref name2, ref value2); reports.Visibility = Visibility.Collapsed; RemoveReportsButton.Visibility = Visibility.Collapsed; AddReportsButton.Visibility = Visibility.Collapsed; EmpsComboBox.Visibility = Visibility.Collapsed; } else { name2 = "Reports:"; RemoveReportsButton.Visibility = Visibility.Visible; reports.Visibility = Visibility.Visible; AddReportsButton.Visibility = Visibility.Visible; EmpsComboBox.Visibility = Visibility.Visible; reports.ItemsSource = (Manager)emp; //set equal to employee list /*EmployeeList empList1 = ; * * foreach (Employee tempEmp in empList1) * { * if(((Manager)emp).CanAddReport(tempEmp) == true) * { * ValidEmps.Add(tempEmp); * empNames.Add(tempEmp.Name); * } * }*/ EmpsComboBox.ItemsSource = empNames; } } }
private void Refresh_Page() { object obj = this.DataContext; this.DataContext = null; this.DataContext = obj; string name1 = ""; string value1 = ""; string name2 = ""; string value2 = ""; emp.SpareDetailProp1(ref name1, ref value1); emp.SpareDetailProp2(ref name2, ref value2); SpareProp1Name.Content = name1; SpareProp1Value.Content = value1; SpareProp2Name.Content = name2; SpareProp2Value.Content = value2; }
public CompDetails(Object data) : this() { this.DataContext = data; if (data is Employee) { Employee emp = (Employee)data; string name1 = ""; string value1 = ""; string name2 = ""; string value2 = ""; emp.SpareDetailProp1(ref name1, ref value1); emp.SpareDetailProp2(ref name2, ref value2); SpareProp1Name.Content = name1; SpareProp1Value.Content = value1; SpareProp2Name.Content = name2; SpareProp2Value.Content = value2; } }