void ReleaseDesignerOutlets()
        {
            if (NameField != null)
            {
                NameField.Dispose();
                NameField = null;
            }

            if (NamespaceField != null)
            {
                NamespaceField.Dispose();
                NamespaceField = null;
            }

            if (AuthorField != null)
            {
                AuthorField.Dispose();
                AuthorField = null;
            }

            if (CopyrightField != null)
            {
                CopyrightField.Dispose();
                CopyrightField = null;
            }
        }
Exemple #2
0
        void Save()
        {
            foreach (var textBox in root.Children.OfType <TextBox>())
            {
                BindingExpression be = textBox.GetBindingExpression(TextBox.TextProperty);
                be?.UpdateSource();
            }
            DateField.GetBindingExpression(DatePicker.SelectedDateProperty).UpdateSource();
            AuthorField.GetBindingExpression(ComboBox.SelectedItemProperty).UpdateSource();
            PublisherField.GetBindingExpression(ComboBox.SelectedItemProperty).UpdateSource();

            var booksCollection = (Application.Current as App).LibraryData.Books;

            if (impactType == ImpactType.Save)
            {
                if (!booksCollection.Contains <Book>(impact))
                {
                    (Application.Current as App).LibraryData.Books.Add(impact);
                }
                else
                {
                    MessageBox.Show("A book with the ISBN has already been added", "Error",
                                    MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            Close();
        }