You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Force serif font to distinguish l from I
The sans serif I looks like l and halfway through the tutorial I realized the mistake, but all the references were wrong in my version so I couldn't copy and paste code making a mess/waste of time. I propose using the inline code delimiter on the code names in order to be explicit.
* typo
Copy file name to clipboardExpand all lines: docs/framework/wpf/getting-started/walkthrough-my-first-wpf-desktop-application.md
+30-30Lines changed: 30 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,15 +44,15 @@ For more information about installing the latest version of Visual Studio, see [
44
44
45
45
The first step is to create the application infrastructure, which includes an application definition, two pages, and an image.
46
46
47
-
1. Create a new WPF Application project in Visual Basic or Visual C# named **ExpenseIt**:
47
+
1. Create a new WPF Application project in Visual Basic or Visual C# named **`ExpenseIt`**:
48
48
49
49
1. Open Visual Studio and select **File** > **New** > **Project**.
50
50
51
51
The **New Project** dialog opens.
52
52
53
53
2. Under the **Installed** category, expand either the **Visual C#** or **Visual Basic** node, and then select **Windows Classic Desktop**.
54
54
55
-
3. Select the **WPF App (.NET Framework)** template. Enter the name **ExpenseIt** and then select **OK**.
55
+
3. Select the **WPF App (.NET Framework)** template. Enter the name **`ExpenseIt`** and then select **OK**.
56
56
57
57

58
58
@@ -91,7 +91,7 @@ The first step is to create the application infrastructure, which includes an ap
91
91
92
92
5. Change the following properties on the <xref:System.Windows.Navigation.NavigationWindow> element:
93
93
94
-
- Set the <xref:System.Windows.Window.Title%2A> property to "ExpenseIt".
94
+
- Set the <xref:System.Windows.Window.Title%2A> property to "`ExpenseIt`".
95
95
96
96
- Set the <xref:System.Windows.FrameworkElement.Width%2A> property to 500 pixels.
97
97
@@ -125,17 +125,17 @@ The first step is to create the application infrastructure, which includes an ap
125
125
126
126
In this section, you'll add two pages and an image to the application.
127
127
128
-
1. Add a new WPF page to the project, and name it *ExpenseItHome.xaml*:
128
+
1. Add a new WPF page to the project, and name it *`ExpenseItHome.xaml`*:
129
129
130
-
1. In **Solution Explorer**, right-click on the **ExpenseIt** project node and choose **Add** > **Page**.
130
+
1. In **Solution Explorer**, right-click on the **`ExpenseIt`** project node and choose **Add** > **Page**.
131
131
132
-
1. In the **Add New Item** dialog, the **Page (WPF)** template is already selected. Enter the name **ExpenseItHome**, and then select **Add**.
132
+
1. In the **Add New Item** dialog, the **Page (WPF)** template is already selected. Enter the name **`ExpenseItHome`**, and then select **Add**.
133
133
134
134
This page is the first page that's displayed when the application is launched. It will show a list of people to select from, to show an expense report for.
135
135
136
-
2. Open *ExpenseItHome.xaml*.
136
+
2. Open *`ExpenseItHome.xaml`*.
137
137
138
-
3. Set the <xref:System.Windows.Controls.Page.Title%2A> to "ExpenseIt - Home".
138
+
3. Set the <xref:System.Windows.Controls.Page.Title%2A> to "`ExpenseIt - Home`".
139
139
140
140
Your XAML should look like this in Visual Basic:
141
141
@@ -147,9 +147,9 @@ In this section, you'll add two pages and an image to the application.
147
147
148
148
4. Open *MainWindow.xaml*.
149
149
150
-
5. Set the <xref:System.Windows.Navigation.NavigationWindow.Source%2A> property on the <xref:System.Windows.Navigation.NavigationWindow> to "ExpenseItHome.xaml".
150
+
5. Set the <xref:System.Windows.Navigation.NavigationWindow.Source%2A> property on the <xref:System.Windows.Navigation.NavigationWindow> to "`ExpenseItHome.xaml`".
151
151
152
-
This sets *ExpenseItHome.xaml* to be the first page opened when the application starts. Your XAML should look like this in Visual Basic:
152
+
This sets *`ExpenseItHome.xaml`* to be the first page opened when the application starts. Your XAML should look like this in Visual Basic:
@@ -164,15 +164,15 @@ In this section, you'll add two pages and an image to the application.
164
164
165
165
6. Add another new WPF page to the project, and name it *ExpenseReportPage.xaml*::
166
166
167
-
1. In **Solution Explorer**, right-click on the **ExpenseIt** project node and choose **Add** > **Page**.
167
+
1. In **Solution Explorer**, right-click on the **`ExpenseIt`** project node and choose **Add** > **Page**.
168
168
169
169
1. In the **Add New Item** dialog, the **Page (WPF)** template is already selected. Enter the name **ExpenseReportPage**, and then select **Add**.
170
170
171
-
This page will show the expense report for the person that is selected on the **ExpenseItHome** page.
171
+
This page will show the expense report for the person that is selected on the **`ExpenseItHome`** page.
172
172
173
173
7. Open *ExpenseReportPage.xaml*.
174
174
175
-
8. Set the <xref:System.Windows.Controls.Page.Title%2A> to "ExpenseIt - View Expense".
175
+
8. Set the <xref:System.Windows.Controls.Page.Title%2A> to "`ExpenseIt - View Expense`".
176
176
177
177
Your XAML should look like this in Visual Basic:
178
178
@@ -186,7 +186,7 @@ In this section, you'll add two pages and an image to the application.
186
186
187
187
When you create a new Page file, Visual Studio automatically creates a *code-behind* file. These code-behind files handle the logic for responding to user input.
188
188
189
-
Your code should look like this for **ExpenseItHome**:
189
+
Your code should look like this for **`ExpenseItHome`**:
Each of these layout controls supports a special type of layout for its child elements. ExpenseIt pages can be resized, and each page has elements that are arranged horizontally and vertically alongside other elements. Consequently, the <xref:System.Windows.Controls.Grid> is the ideal layout element for the application.
226
+
Each of these layout controls supports a special type of layout for its child elements. `ExpenseIt` pages can be resized, and each page has elements that are arranged horizontally and vertically alongside other elements. Consequently, the <xref:System.Windows.Controls.Grid> is the ideal layout element for the application.
227
227
228
228
> [!TIP]
229
229
> For more information about <xref:System.Windows.Controls.Panel> elements, see [Panels overview](../../../../docs/framework/wpf/controls/panels-overview.md). For more information about layout, see [Layout](../../../../docs/framework/wpf/advanced/layout.md).
230
230
231
-
In the section, you create a single-column table with three rows and a 10-pixel margin by adding column and row definitions to the <xref:System.Windows.Controls.Grid> in *ExpenseItHome.xaml*.
231
+
In the section, you create a single-column table with three rows and a 10-pixel margin by adding column and row definitions to the <xref:System.Windows.Controls.Grid> in *`ExpenseItHome.xaml`*.
232
232
233
-
1. Open *ExpenseItHome.xaml*.
233
+
1. Open *`ExpenseItHome.xaml`*.
234
234
235
235
2. Set the <xref:System.Windows.FrameworkElement.Margin%2A> property on the <xref:System.Windows.Controls.Grid> element to "10,0,10,10", which corresponds to left, top, right and bottom margins:
236
236
@@ -257,15 +257,15 @@ In the section, you create a single-column table with three rows and a 10-pixel
257
257
258
258
In this section, you'll update the home page UI to show a list of people that a user can select from to show the expense report for. Controls are UI objects that allow users to interact with your application. For more information, see [Controls](../../../../docs/framework/wpf/controls/index.md).
259
259
260
-
To create this UI, you'll add the following elements to *ExpenseItHome.xaml*:
260
+
To create this UI, you'll add the following elements to *`ExpenseItHome.xaml`*:
261
261
262
262
-<xref:System.Windows.Controls.ListBox> (for the list of people).
263
263
-<xref:System.Windows.Controls.Label> (for the list header).
264
264
-<xref:System.Windows.Controls.Button> (to click to view the expense report for the person that is selected in the list).
265
265
266
266
Each control is placed in a row of the <xref:System.Windows.Controls.Grid> by setting the <xref:System.Windows.Controls.Grid.Row%2A?displayProperty=nameWithType> attached property. For more information about attached properties, see [Attached Properties Overview](../../../../docs/framework/wpf/advanced/attached-properties-overview.md).
267
267
268
-
1. Open *ExpenseItHome.xaml*.
268
+
1. Open *`ExpenseItHome.xaml`*.
269
269
270
270
2. Add the following XAML somewhere between the <xref:System.Windows.Controls.Grid> tags:
271
271
@@ -284,7 +284,7 @@ The following illustration shows the controls you just created:
284
284
285
285
In this section, you'll update the home page UI with an image and a page title.
286
286
287
-
1. Open *ExpenseItHome.xaml*.
287
+
1. Open *`ExpenseItHome.xaml`*.
288
288
289
289
2. Add another column to the <xref:System.Windows.Controls.Grid.ColumnDefinitions%2A> with a fixed <xref:System.Windows.Controls.ColumnDefinition.Width%2A> of 230 pixels:
290
290
@@ -318,13 +318,13 @@ The following illustration shows the results of what you just added:
318
318
319
319
## Add code to handle events
320
320
321
-
1. Open *ExpenseItHome.xaml*.
321
+
1. Open *`ExpenseItHome.xaml`*.
322
322
323
323
2. Add a <xref:System.Windows.Controls.Primitives.ButtonBase.Click> event handler to the <xref:System.Windows.Controls.Button> element. For more information, see [How to: Create a simple event handler](http://msdn.microsoft.com/library/b1456e07-9dec-4354-99cf-18666b64f480).
3. Open *ExpenseItHome.xaml.vb* or *ExpenseItHome.xaml.cs*.
327
+
3. Open *`ExpenseItHome.xaml.vb`* or *`ExpenseItHome.xaml.cs`*.
328
328
329
329
4. Add the following code to the `ExpenseItHome` class to add a button click event handler. The event handler opens the **ExpenseReportPage** page.
330
330
@@ -333,15 +333,15 @@ The following illustration shows the results of what you just added:
333
333
334
334
## Create the UI for ExpenseReportPage
335
335
336
-
*ExpenseReportPage.xaml* displays the expense report for the person that's selected on the **ExpenseItHome** page. In this section, you'll controls and create the UI for **ExpenseReportPage**. You'll also add background and fill colors to the various UI elements.
336
+
*ExpenseReportPage.xaml* displays the expense report for the person that's selected on the **`ExpenseItHome`** page. In this section, you'll create the UI for **ExpenseReportPage**. You'll also add background and fill colors to the various UI elements.
337
337
338
338
1. Open *ExpenseReportPage.xaml*.
339
339
340
340
2. Add the following XAML between the <xref:System.Windows.Controls.Grid> tags:
This UI is similar to *ExpenseItHome.xaml*, except the report data is displayed in a <xref:System.Windows.Controls.DataGrid>.
344
+
This UI is similar to *`ExpenseItHome.xaml`*, except the report data is displayed in a <xref:System.Windows.Controls.DataGrid>.
345
345
346
346
3. Build and run the application.
347
347
@@ -378,11 +378,11 @@ The appearance of various elements is often the same for all elements of the sam
378
378
379
379
-`listHeaderTextStyle`: To format the list header <xref:System.Windows.Controls.Label>.
380
380
381
-
-`buttonStyle`: To format the <xref:System.Windows.Controls.Button> on ExpenseItHome.xaml.
381
+
-`buttonStyle`: To format the <xref:System.Windows.Controls.Button> on `ExpenseItHome.xaml`.
382
382
383
383
Notice that the styles are resources and children of the <xref:System.Windows.Application.Resources%2A?displayProperty=nameWithType> property element. In this location, the styles are applied to all the elements in an application. For an example of using resources in a .NET Framework application, see [Use Application Resources](../../../../docs/framework/wpf/advanced/how-to-use-application-resources.md).
384
384
385
-
3. Open *ExpenseItHome.xaml*.
385
+
3. Open *`ExpenseItHome.xaml`*.
386
386
387
387
4. Replace everything between the <xref:System.Windows.Controls.Grid> elements with the following XAML:
388
388
@@ -402,7 +402,7 @@ The appearance of various elements is often the same for all elements of the sam
402
402
403
403
In this section, you'll create the XML data that is bound to various controls.
404
404
405
-
1. Open *ExpenseItHome.xaml*.
405
+
1. Open *`ExpenseItHome.xaml`*.
406
406
407
407
2. After the opening <xref:System.Windows.Controls.Grid> element, add the following XAML to create an <xref:System.Windows.Data.XmlDataProvider> that contains the data for each person:
408
408
@@ -428,7 +428,7 @@ In this section, you'll create the XML data that is bound to various controls.
428
428
429
429
## Connect data to controls
430
430
431
-
Next, you'll add code to retrieve the name that's selected on the **ExpenseItHome** page and pass it to the constructor of **ExpenseReportPage**. **ExpenseReportPage** sets its data context with the passed item, which is what the controls defined in *ExpenseReportPage.xaml* bind to.
431
+
Next, you'll add code to retrieve the name that's selected on the **`ExpenseItHome`** page and pass it to the constructor of **ExpenseReportPage**. **ExpenseReportPage** sets its data context with the passed item, which is what the controls defined in *ExpenseReportPage.xaml* bind to.
432
432
433
433
1. Open *ExpenseReportPage.xaml.vb* or *ExpenseReportPage.xaml.cs*.
434
434
@@ -437,7 +437,7 @@ Next, you'll add code to retrieve the name that's selected on the **ExpenseItHom
3. Open *ExpenseItHome.xaml.vb* or *ExpenseItHome.xaml.cs*.
440
+
3. Open *`ExpenseItHome.xaml.vb`* or *`ExpenseItHome.xaml.cs`*.
441
441
442
442
4. Change the <xref:System.Windows.Controls.Primitives.ButtonBase.Click> event handler to call the new constructor passing the expense report data of the selected person.
443
443
@@ -466,7 +466,7 @@ In this section, you'll update the UI for each item in the data-bound lists by u
466
466
467
467
6. Select a person and then select the **View** button.
468
468
469
-
The following illustration shows both pages of the ExpenseIt application with controls, layout, styles, data binding, and data templates applied:
469
+
The following illustration shows both pages of the `ExpenseIt` application with controls, layout, styles, data binding, and data templates applied:
0 commit comments