How do I validate the current tab before selection changes to another tab on user click?

Unfortunately, WPF doesn’t provide a straight forward way of validating a tab page’s content before switching to a new tab, in the first version. One workaround is to listen to the TabItem’s PreviewLostKeyboardFocus event and mark it as Handled as shown below. [C#] public TabValidation() { InitializeComponent(); foreach (TabItem item in tabControl1.Items) { item.PreviewLostKeyboardFocus += new KeyboardFocusChangedEventHandler(item_PreviewLostKeyboardFocus); } } void item_PreviewLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) { // sender is the TabItem. if (this.ValidateTab() == false) e.Handled = true; }

How do I listen to text changed events in a ComboBox in editable mode?

Unfortunately, the first version of WPF does not provide a TextChanged event for a ComboBox like the one available for a TextBox. So, a workaround like the following is required: [C#] public Window1() { InitializeComponent(); this.comboBox.Loaded += delegate { TextBox editTextBox = comboBox.Template.FindName(‘PART_EditableTextBox’, comboBox) as TextBox; if (editTextBox != null) { editTextBox.TextChanged += delegate { MessageBox.Show(comboBox.Text); }; } }; }

How do I dynamically hide/unhide tabs in a TabControl?

You can dynamically remove and inseret TabPages into the TabControl.TabPages collection to hide and show tabs at runtime. TabPage tabPageSave = null; private void button1_Click(object sender, EventArgs e) { //hide a tab by removing it from the TabPages collection this.tabPageSave = tabControl1.SelectedTab; this.tabControl1.TabPages.Remove(this.tabPageSave); } private void button2_Click(object sender, EventArgs e) { //show a tab by adding it to the TabPages collection if (this.tabPageSave != null) { int loc = tabControl1.SelectedIndex; this.tabControl1.TabPages.Insert(loc, this.tabPageSave); } }