
Adding the Notepad Part and View
"Acropolis" parts contain the business logic that a user will interact with. For more information about parts, see Acropolis Parts and Forms. Typically, parts, which contain business logic, are separated from their user interface. The user interface portion for a part is called a view. For more information about part views, see Acropolis Part Views.
The majority of the business logic for the Notepad application is contained in a single part. You will add the Notepad part and view as described in the following procedure. Similar to Window1, the Notepad part and view include a XAML file and a code-behind file nested underneath it in Solution Explorer. The Notepad part extends DocumentPartBase, which provides command handlers and other infrastructure required for a document-centric part. When you add the part to the project and compile it, the part is made available to the application as a template on the Toolbox. The template provides the application with the association between the file extension and part used to open the file. You will add two part templates to Application.xaml; one for text files and one for C# or Visual Basic files.
To add the notepad part and view
In Solution Explorer, right-click the Notepad project and select Add | New Item.
The Add New Item dialog box appears.
Select the Acropolis Document Part and View template, change the name to NotepadPart.xaml and then click Add.
The Notepad part appears in the "Acropolis" designer.
Build the project. This will add a Notepad part template to the Toolbox.
Note: |
|---|
The Toolbox will be empty if XAML view has the focus. To restore the Toolbox contents in this case, click in Design view. |
The following illustration shows the "Acropolis" Toolbox tabs that are present at this point of building the application.
Select the Application.xaml tab to display Application.xaml in the designer.
From the Toolbox in the UserDocument Templates (Notepad) tab, double-click NotepadPart Template to add a Notepad part template to the Templates section of the design surface.
In the designer, make sure the Notepad Document Template is selected and in the Properties window, set the FileExtension property to .txt.
Add a second NotepadPart template.
Set its FileExtension property to .cs or .vb depending on the language you are using for this walkthrough.