public MainWindow() { InitializeComponent(); DbAction.CreateDatabase(); if (selection.SelectedIndex == 1) { selection2.Visibility = Visibility.Hidden; itemName.Visibility = Visibility.Visible; selection4.Visibility = Visibility.Visible; classList = new ObservableCollection <Classes>(DbAction.QueryClasses()); itemsList = new ObservableCollection <Equipment>(DbAction.QueryItems()); itemPrice.Visibility = Visibility.Visible; if (classList.Count() != 0) { selection4.ItemsSource = classList; actionbutton.Visibility = Visibility.Visible; } else { selection4.IsEnabled = false; } } Classrooms.ItemsSource = classList; Items.ItemsSource = itemsList; }
private void Actionbutton_Click(object sender, RoutedEventArgs e) { if (selection.SelectedIndex == 0) { Classes claz = new Classes(); claz.ClassName = 11;//int.Parse(nameclass.Text); DbAction.InsertToDB(claz); classList.Add(claz); } }