TabControl

View as Markdown

Definition

The TabControl class provides functionality for working with NTTabPage objects within an NTWindow. TabControl should be instantiated within the constructor for an NTWindow instance, in order to configure the window to be able to host and work with tabs.

Note: For a complete, working example of this class in use, download framework example located on our Developing AddOns Overview.

Examples

In the example below, we define an instance of NTWindow, then use TabControl to accomplish various setup tasks:

  • Provide the NTWindow with the ability to add, remove, and move tabs
  • Attach a Factory to the TabControl to handle logic for creating new tabs
  • Set up the TabControl with the ability to utilize window linking
1public class MyWindow : NTWindow, IWorkspacePersistence
2{
3 public MyWindow()
4 {
5 // TabControl should be created for window content if tab features are wanted
6 TabControl tc = new TabControl();
7
8 // Attached properties defined in the TabControlManager class should be set to add, remove, or move tabs
9 TabControlManager.SetIsMovable(tc, true);
10 TabControlManager.SetCanAddTabs(tc, true);
11 TabControlManager.SetCanRemoveTabs(tc, true);
12
13 // if the ability to add new tabs is desired, TabControl must have attached property "Factory" set.
14 TabControlManager.SetFactory(tc, new MyWindowFactory());
15 Content = tc;
16
17 /* In order to have link buttons functionality, tab control items must be derived from Tools.NTTabPage
18 They can be added using extention method AddNTTabPage(NTTabPage page) */
19 tc.AddNTTabPage(new MyTab());
20 }
21}
22
23/* Class which implements Tools.INTTabFactory must be created and set as an attached property for TabControl
24in order to use tab page add/remove/move/duplicate functionality */
25public class MyWindowFactory : INTTabFactory
26{
27 // INTTabFactory member. Required to create parent window
28 public NTWindow CreateParentWindow()
29 {
30 return new MyWindow();
31 }
32
33 // INTTabFactory member. Required to create tabs
34 public NTTabPage CreateTabPage(string typeName, bool isTrue)
35 {
36 return new MyTab();
37 }
38}