private void AddTabBook(Book book, bool isNew)
        {
            var ctl = new BookDetailView(book, isNew);
            var tab = new TabItem()
            {
                Header  = isNew ? "<new member>" : book.Isbn,
                Content = ctl
            };

            tab.MouseDown += (o, e) => {
                if (e.ChangedButton == MouseButton.Middle &&
                    e.ButtonState == MouseButtonState.Pressed)
                {
                    tabControl.Items.Remove(o);
                    (tab.Content as UserControlBase).Dispose();
                }
            };
            tab.PreviewKeyDown += (o, e) => {
                if (e.Key == Key.W && Keyboard.IsKeyDown(Key.LeftCtrl))
                {
                    tabControl.Items.Remove(o);
                    (tab.Content as UserControlBase).Dispose();
                }
            };
            // ajoute ce onglet à la liste des onglets existant du TabControl
            tabControl.Items.Add(tab);
            // exécute la méthode Focus() de l'onglet pour lui donner le focus (càd l'activer)
            Dispatcher.InvokeAsync(() => tab.Focus());
        }
Beispiel #2
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.root = ((prbd_1819_g10.BookDetailView)(target));
                return;

            case 2:
                this.txtIsbn = ((System.Windows.Controls.TextBox)(target));
                return;

            case 3:
                this.txtTitle = ((System.Windows.Controls.TextBox)(target));
                return;

            case 4:
                this.txtAuthor = ((System.Windows.Controls.TextBox)(target));
                return;

            case 5:
                this.txtEditor = ((System.Windows.Controls.TextBox)(target));
                return;

            case 6:
                this.img = ((System.Windows.Controls.Image)(target));
                return;

            case 7:
                this.btnLoad = ((System.Windows.Controls.Button)(target));
                return;

            case 8:
                this.btnClear = ((System.Windows.Controls.Button)(target));
                return;

            case 9:
                this.copies = ((System.Windows.Controls.StackPanel)(target));
                return;

            case 10:
                this.myUpDownControl = ((Xceed.Wpf.Toolkit.IntegerUpDown)(target));
                return;

            case 11:
                this.txtAddCopies = ((System.Windows.Controls.Button)(target));
                return;

            case 12:
                this.btnCancel = ((System.Windows.Controls.Button)(target));
                return;

            case 13:
                this.btnSave = ((System.Windows.Controls.Button)(target));
                return;

            case 14:
                this.btnDelete = ((System.Windows.Controls.Button)(target));
                return;
            }
            this._contentLoaded = true;
        }