WPF Tabs Handling |
WPF tabs handling. Sets the last selected tab.
This topic contains the following sections:
Go to "Solution Explorer", project "Properties", tab "Settings"
Create a entry item called TabPageIndex of type "int" on scope "User"
Class based on WPF Window
/// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { //... }
Construtor - sets tab
/// <summary> /// Initializes a new instance of the MainWindow class. /// Constructor without parameter /// </summary> public MainWindow() { InitializeComponent(); this.TabMain.SelectedIndex = Properties.Settings.Default.TabPageIndex; // ... }
Tab selection handling
/// <summary> /// Tab selection changed /// </summary> /// <param name="sender">TabMain object</param> /// <param name="e"></param> private void TabMain_SelectionChanged(object sender, SelectionChangedEventArgs e) { Properties.Settings.Default.TabPageIndex = TabMain.SelectedIndex; }
Save settings
/// <summary> /// Save settings /// </summary> protected override void OnClosing(CancelEventArgs e) { SOWIWin.Tool.Properties.Settings.Default.Save(); base.OnClosing(e); }