private void btnExecute_Click(object sender, RoutedEventArgs e) { var x = (Parent)this.DataContext; if (x.IsValidate()) { if (DBMain.InsertData(x)) { BaseDataBase.MakeTabItemGreen(this.Parent as TabItem); MyMessage.InsertMessage(); btnExecute.Visibility = System.Windows.Visibility.Hidden; btnUpdate.Visibility = System.Windows.Visibility.Visible; } } }
void ParentControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { if (e.NewValue is Parent) { if ((e.NewValue as Parent).Gender == "ذكر") { chkIsNursemaid.Visibility = txtIsNursemaid.Visibility = btnTraining.Visibility = System.Windows.Visibility.Collapsed; } if (((Parent)e.NewValue).ParentrID != null) { btnUpdate.Visibility = System.Windows.Visibility.Visible; btnExecute.Visibility = System.Windows.Visibility.Hidden; BaseDataBase.MakeTabItemGreen(this.Parent as TabItem); } else { btnUpdate.Visibility = System.Windows.Visibility.Hidden; btnExecute.Visibility = System.Windows.Visibility.Visible; BaseDataBase.MakeTabItemRed(this.Parent as TabItem); } } }