When we wrote the dialog to rename pages, we had in mind that you'd also use it to ask the user for a name when creating new pages. If ShowDialog is called with False as the second argument, then the dialog is shown with an appropriate title for naming a new page.
You already have a method on the tab controller for creating a new tab page: add-TabPage. This only deals with the view, though; it adds a tab page to the tab control, but it doesn't create a new page on the document. addTabPage is called when you load new documents, which already have pages. You need a new method that will handle both the model and the view for you, calling down to addTabPage for the view. This is the newPage method, shown in listing 6.15. The second argument to addTabPage is an empty string because the freshly created page has no text in it yet.
Was this article helpful?