This tutorial teaches you how to create a simple "Hello, world"Windows Store app using Extensible Application Markup Language (XAML) with Microsoft Visual Basic or C#. It's the first tutorial in a series that teach you what you need to know to build any type of Windows Store app you want.
Step 1: Create a new project in Visual Studio
- Launch Visual Studio Express 2012 for Windows 8. The Visual Studio Express 2012 for Windows 8 start screen appears.
(Going forward, we'll refer to Visual Studio Express 2012 for Windows 8 as just "Visual Studio".)
- Select File > New Project. The New Project dialog appears. The left pane of the dialog lets you select the type of templates to display.
-
In the left pane, expand Installed, then expand Visual Basic or Visual C# and select the Windows Store template type. The dialog's center pane displays a list of project templates for Windows Store apps.
For this tutorial, we use the Blank App template. The Blank App
template creates a minimal Windows Store app that compiles and runs,
but contains no user interface controls or data. You add controls and
data to the app over the course of these tutorials.
- In the center pane, select the Blank App template.
- In the Name text box, enter "HelloWorld".
- Click OK to create the project. Microsoft Visual Studio creates your project and displays it in the Solution Explorer.
- A manifest file (package.appxmanifest) that describes your app (its name, description, tile, start page, and so on) and lists the files that your app contains.
- A set of large and small logo images (logo.png and smalllogo.png)to display in the start screen.
- An image (storelogo.png) to represent your app in the Windows Store.
- A splash screen (splashscreen.png) to show when your app starts.
- XAML and code files for the app (App.xaml and App.xaml.cs/.vb) .
- A start page (MainPage.xaml) and an accompanying code file (MainPage.xaml.cs/.vb) that run when your app starts.
Replace the MainPage
The MainPage in the Blank App project template is based on the Blank Page template. It contains the minimum amount of XAML and code to instantiate a Page. The other project and Page templates in Visual Studio include some additional code and helper classes that help you get started with your Windows Store app. When you use the Blank App project template, you can replace the blank MainPage with one of the other Page templates to take advantage of the layout and helper classes they provide. In this example, you replace the default MainPage with the Basic Page template. Later tutorials in this series depend on the helper classes used by the Basic Page template.To replace MainPage in the blank app
- In Solution Explorer, right-click MainPage.xaml and select Delete.
- Click OK to confirm the deletion.
- Select Project > Add New Item. The Add New Item dialog box opens. It looks similar to the New Project dialog.
- In the Installed pane, expand Visual C# or Visual Basic.
- Pick the Windows Store template type.
- In the center pane, select the type of page to add to your project. For this example, select Basic Page.
- Enter a name for the page. For this example, enter "MainPage".
- Click Add.The first time you add a new page to the Blank App template (other than a Blank Page), Visual Studio shows a dialog with a message that the addition depends on files that are missing from your project. Click Yes to add these files. Files for several utility classes are added to your project in the Common folder.
The XAML and code behind files for your page are added to the project.
- Press F7 to build the app. The new page will show an error in the designer until you build the helper classes it depends on.
And how do you build the helper classes it depends on?
ReplyDelete