Skip to content

Commit b44ea69

Browse files
authored
Merge pull request #4183 from ghogen/dev16-wpf
Dev16 updates for WPF tutorials
2 parents 3afc417 + 336ed34 commit b44ea69

17 files changed

+100
-69
lines changed
Loading
Loading
Loading

docs/get-started/csharp/tutorial-uwp.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
title: Create a Universal Windows Platform (UWP) App with Visual Studio and C#
23
description: Create a UWP app in Visual Studio with XAML and C#
34
titleSuffix: ""
45
ms.custom: "seodec18, get-started"
@@ -16,7 +17,7 @@ ms.workload:
1617
---
1718
# Tutorial: Create your first Universal Windows Platform application in Visual Studio with XAML and C#
1819

19-
In this 5-10 minute introduction to the Visual Studio integrated development environment (IDE), you'll create a "Hello World" app that runs on any Windows 10 device. To do so, you'll use a Universal Windows Platform (UWP) project template, Extensible Application Markup Language (XAML), and the C# programming language.
20+
In this introduction to the Visual Studio integrated development environment (IDE), you'll create a "Hello World" app that runs on any Windows 10 device. To do so, you'll use a Universal Windows Platform (UWP) project template, Extensible Application Markup Language (XAML), and the C# programming language.
2021

2122
::: moniker range="vs-2017"
2223
If you haven't already installed Visual Studio, go to the [Visual Studio downloads](https://visualstudio.microsoft.com/downloads/?utm_medium=microsoft&utm_source=docs.microsoft.com&utm_campaign=inline+link&utm_content=download+vs2017) page to install it for free.
@@ -44,23 +45,25 @@ First, create a Universal Windows Platform project. The project type comes with
4445
4546
4. Accept the default **Target version** and **Minimum version** settings in the **New Universal Windows Platform Project** dialog box.
4647

47-
![Accept the default Target version and Minimum version settings in the New Universal Windows Platform Project dialog box](media/new-uwp-project-target-minver-dialog.png)
48+
![Accept the default Target version and Minimum version settings in the New Universal Windows Platform Project dialog box](media/new-uwp-project-target-minver-dialog.png)
4849
::: moniker-end
4950

5051
::: moniker range=">=vs-2019"
5152

52-
2. Start Visual Studio, and on the **Start Window**, choose **Create a new project**.
53+
2. Start Visual Studio, and on the **Start** window, choose **Create a new project**.
5354

5455
3. On the **Create a new project** screen, enter *Universal Windows* in the search box, choose the C# template for **Blank App (Universal Windows)**, and then choose **Next**.
5556

56-
![Screenshot of Create a new project screen](media/vs-2019/uwp-create-new-project.png)
57+
![Screenshot of Create a new project screen](media/vs-2019/uwp-create-new-project.png)
58+
59+
> [!NOTE]
60+
> If you don't see the **Blank App (Universal Windows)** project template, click the **Install more tools and features** link.<br><br>![Click the Install more tools and features link](media/vs-2019/uwp-not-finding.png)<br><br>The Visual Studio Installer launches. Choose the **Universal Windows Platform development** workload, and then choose **Modify**.<br><br>![Universal Windows Platform development workload in the Visual Studio Installer](media/uwp-dev-workload.png)
5761
5862
4. Accept the default **Target version** and **Minimum version** settings in the **New Universal Windows Platform Project** dialog box.
5963

60-
![Accept the default Target version and Minimum version settings in the New Universal Windows Platform Project dialog box](media/vs-2019/new-uwp-project-target-minver-dialog.png)
64+
![Accept the default Target version and Minimum version settings in the New Universal Windows Platform Project dialog box](media/vs-2019/new-uwp-project-target-minver-dialog.png)
6165
::: moniker-end
6266

63-
6467
> [!NOTE]
6568
> If this is the first time you have used Visual Studio to create a UWP app, a **Settings** dialog box might appear. Choose **Developer mode**, and then choose **Yes**.<br><br>
6669
![Enable the Developer Mode in the UWP Settings dialog box](media/enable-developer-mode.png)<br><br>Visual Studio installs an additional Developer Mode package for you. When the package installation is complete, close the **Settings** dialog box.

docs/get-started/csharp/tutorial-wpf.md

Lines changed: 44 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: "Tutorial: Hello World app with Windows Presentation Foundation (WPF) in C#"
33
description: Create a simple Windows Desktop .NET app in C# with Visual Studio using the Windows Presentation Foundation (WPF) UI framework.
44
ms.custom: "seodec18, get-started"
5-
ms.date: 10/03/2017
5+
ms.date: 03/14/2019
66
ms.technology: vs-ide-general
77
ms.topic: conceptual
88
dev_langs:
@@ -16,17 +16,22 @@ ms.workload:
1616
---
1717
# Tutorial: Create a simple application with C\#
1818

19-
By completing this walkthrough, you'll become familiar with many of the tools, dialog boxes, and designers that you can use when you develop applications with Visual Studio. You'll create a "Hello, World" application, design the UI, add code, and debug errors, while you learn about working in the integrated development environment ([IDE](visual-studio-ide.md)).
19+
By completing this tutorial, you'll become familiar with many of the tools, dialog boxes, and designers that you can use when you develop applications with Visual Studio. You'll create a "Hello, World" application, design the UI, add code, and debug errors, while you learn about working in the integrated development environment ([IDE](visual-studio-ide.md)).
2020

21+
::: moniker range="vs-2017"
2122
If you haven't already installed Visual Studio, go to the [Visual Studio downloads](https://visualstudio.microsoft.com/downloads/?utm_medium=microsoft&utm_source=docs.microsoft.com&utm_campaign=inline+link&utm_content=download+vs2017) page to install it for free.
23+
::: moniker-end
24+
::: moniker range=">=vs-2019"
25+
If you haven't already installed Visual Studio, go to the [Visual Studio downloads](https://visualstudio.microsoft.com/downloads/?utm_medium=microsoft&utm_source=docs.microsoft.com&utm_campaign=inline+link&utm_content=download+vs2019+rc) page to install it for free.
26+
::: moniker-end
2227

2328
## Configure the IDE
2429

25-
When you start Visual Studio for the first time, you'll be prompted to sign in. This step is optional for this walkthrough. Next you may be shown a dialog box that asks you to choose your development settings and color theme. Keep the defaults and choose **Start Visual Studio**.
30+
::: moniker range="vs-2017"
2631

27-
![Choose settings dialog box](../media/exploreide-settings.png)
32+
When you start Visual Studio for the first time, you'll be prompted to sign in. This step is optional for this tutorial. Next you may be shown a dialog box that asks you to choose your development settings and color theme. Keep the defaults and choose **Start Visual Studio**.
2833

29-
::: moniker range="vs-2017"
34+
![Choose settings dialog box](../media/exploreide-settings.png)
3035

3136
After Visual Studio launches, you'll see tool windows, the menus and toolbars, and the main window space. Tool windows are docked on the left and right sides of the application window, with **Quick Launch**, the menu bar, and the standard toolbar at the top. In the center of the application window is the **Start Page**. When you load a solution or project, editors and designers appear in the space where the **Start Page** is. When you develop an application, you'll spend most of your time in this central area.
3237

@@ -36,7 +41,7 @@ After Visual Studio launches, you'll see tool windows, the menus and toolbars, a
3641

3742
::: moniker range=">=vs-2019"
3843

39-
When you launch Visual Studio, the **Start** window opens first. Select **Contine without code** to open the development environment. You'll see tool windows, the menus and toolbars, and the main window space. Tool windows are docked on the left and right sides of the application window, with **Quick Launch**, the menu bar, and the standard toolbar at the top. When you load a solution or project, editors and designers appear in the central space of the application window. When you develop an application, you'll spend most of your time in this central area.
44+
When you launch Visual Studio, the **Start** window opens first. Select **Continue without code** to open the development environment. You'll see tool windows, the menus and toolbars, and the main window space. Tool windows are docked on the left and right sides of the application window, with **Quick Launch**, the menu bar, and the standard toolbar at the top. When you load a solution or project, editors and designers appear in the central space of the application window. When you develop an application, you'll spend most of your time in this central area.
4045

4146
::: moniker-end
4247

@@ -46,20 +51,37 @@ When you create an application in Visual Studio, you first create a project and
4651

4752
1. Create a new project. On the menu bar, select **File** > **New** > **Project**.
4853

54+
::: moniker range="vs-2017"
4955
![On the menu bar, choose File, New, Project](../media/exploreide-filenewproject.png)
56+
::: moniker-end
57+
::: moniker range=">=vs-2019"
58+
[On the menu bar, choose File, New, Project](../media/vs-2019/exploreide-filenewproject-vs2019.png)
59+
::: moniker-end
5060

51-
1. In the **New Project** dialog, select the **Installed** > **Visual C#** > **Windows Desktop** category, and then select the **WPF App (.NET Framework)** template. Name the project **HelloWPFApp**.
61+
::: moniker range="vs-2017"
62+
2. In the **New Project** dialog, select the **Installed** > **Visual C#** > **Windows Desktop** category, and then select the **WPF App (.NET Framework)** template. Name the project **HelloWPFApp**, and select **OK**.
5263

5364
![WPF app template in Visual Studio New Project dialog](media/exploreide-newprojectcsharp.png)
65+
::: moniker-end
66+
::: moniker range=">=vs-2019"
67+
2. On the **Create a new project** screen, search for "WPF," choose **WPF App (.NET Framework)**, and then choose **Next**.
5468

55-
1. Select **OK**.
69+
![WPF app template in Visual Studio New Project dialog](media/vs-2019/exploreide-newprojectcsharp-vs2019.png)
5670

57-
Visual Studio creates the HelloWPFApp project and solution, and **Solution Explorer** shows the various files. The **WPF Designer** shows a design view and a XAML view of *MainWindow.xaml* in a split view. You can slide the splitter to show more or less of either view. You can choose to see only the visual view or only the XAML view. The following items appear in **Solution Explorer**:
71+
3. At the next screen, give the project a name, **HelloWPFApp**, and choose **Create**.
72+
::: moniker-end
5873

59-
![Solution Explorer with HelloWPFApp files loaded](../media/exploreide-hellowpfappfiles.png)
74+
Visual Studio creates the HelloWPFApp project and solution, and **Solution Explorer** shows the various files. The **WPF Designer** shows a design view and a XAML view of *MainWindow.xaml* in a split view. You can slide the splitter to show more or less of either view. You can choose to see only the visual view or only the XAML view. The following items appear in **Solution Explorer**:
6075

61-
> [!NOTE]
62-
> For more information about XAML (eXtensible Application Markup Language), see the [XAML overview for WPF](/dotnet/framework/wpf/advanced/xaml-overview-wpf) page.
76+
::: moniker range="vs-2017"
77+
![Solution Explorer with HelloWPFApp files loaded](../media/exploreide-hellowpfappfiles.png)
78+
::: moniker-end
79+
::: moniker range=">=vs-2019"
80+
![Solution Explorer with HelloWPFApp files loaded](../media/vs-2019/exploreide-hellowpfappfiles.png)
81+
::: moniker-end
82+
83+
> [!NOTE]
84+
> For more information about XAML (eXtensible Application Markup Language), see the [XAML overview for WPF](/dotnet/framework/wpf/advanced/xaml-overview-wpf) page.
6385
6486
After you create the project, you can customize it. By using the **Properties** window (found on the **View** menu), you can display and change options for project items, controls, and other items in an application.
6587

@@ -81,7 +103,7 @@ We will add three types of controls to this application: a <xref:System.Windows.
81103

82104
### Add a TextBlock control
83105

84-
1. Open the **Toolbox** window by choosing the **View** menu and the **Toolbox** item.
106+
1. Enter **Ctrl**+**Q** to invoke **Quick Launch** and type **Toolbox**. Choose **View > Toolbox** from the results list.
85107

86108
2. In the **Toolbox**, expand the **Common WPF Controls** node to see the TextBlock control.
87109

@@ -107,7 +129,7 @@ The XAML markup should look something like the following example:
107129
Text="Select a message option and then choose the Display button."
108130
```
109131

110-
2. Center the TextBlock again if necessary, and save your changes by pressing **Ctrl**+**S** or using the **File** menu item.
132+
2. Center the TextBlock again if necessary, and save your changes by pressing Ctrl+S or using the **File** menu item.
111133

112134
Next, you'll add two [RadioButton](/dotnet/framework/wpf/controls/radiobutton) controls to the form.
113135

@@ -121,7 +143,7 @@ Next, you'll add two [RadioButton](/dotnet/framework/wpf/controls/radiobutton) c
121143

122144
Your window should look like this:
123145

124-
![Greetings form with textblock and two radiobuttons](../media/exploreide-greetingswithradiobuttons.png)
146+
![Greetings form with TextBlock and two radio buttons](../media/exploreide-greetingswithradiobuttons.png)
125147

126148
3. In the **Properties** window for the left RadioButton control, change the **Name** property (the property at the top of the **Properties** window) to `HelloButton`.
127149

@@ -202,17 +224,15 @@ In this step, you'll find the error that we caused earlier by changing the name
202224

203225
#### Start debugging and find the error
204226

205-
1. Start the debugger by selecting **Debug**, then **Start Debugging**.
227+
1. Start the debugger by pressing **F5** or selecting **Debug**, then **Start Debugging**.
206228

207-
![Start Debugging command on the Debug menu](../media/exploreide-startdebugging.png)
229+
A **Break Mode** window appears, and the **Output** window indicates that an IOException has occurred: Cannot locate resource 'mainwindow.xaml'.
208230

209-
A **Break Mode** window appears, and the **Output** window indicates that an IOException has occurred: Cannot locate resource 'mainwindow.xaml'.
231+
![Screenshot of IOException message](../media/exploreide-ioexception.png)
210232

211233
2. Stop the debugger by choosing **Debug** > **Stop Debugging**.
212234

213-
![Stop Debugging command on the Debug menu](../media/exploreide-stopdebugging.png)
214-
215-
We renamed *MainWindow.xaml* to *Greetings.xaml* at the start of this walkthrough, but the code still refers to *MainWindow.xaml* as the startup URI for the application, so the project can't start.
235+
We renamed *MainWindow.xaml* to *Greetings.xaml* at the start of this tutorial, but the code still refers to *MainWindow.xaml* as the startup URI for the application, so the project can't start.
216236

217237
#### Specify Greetings.xaml as the startup URI
218238

@@ -232,8 +252,6 @@ You can test the code during debugging by adding some breakpoints. You can add b
232252

233253
2. Add a breakpoint from the menu by selecting **Debug**, then **Toggle Breakpoint**.
234254

235-
![Toggle Breakpoint command on the Debug menu](../media/exploreide-togglebreakpoint.png)
236-
237255
A red circle appears next to the line of code in the far left margin of the editor window.
238256

239257
3. Select the following line: `MessageBox.Show("Goodbye.")`.
@@ -242,7 +260,9 @@ You can test the code during debugging by adding some breakpoints. You can add b
242260

243261
5. In the **Greetings** window, choose the **Hello** radio button, and then choose the **Display** button.
244262

245-
The line `MessageBox.Show("Hello.")` is highlighted in yellow. At the bottom of the IDE, the Autos, Locals, and Watch windows are docked together on the left side, and the Call Stack, Breakpoints, Command, Immediate, and Output windows are docked together on the right side.
263+
The line `MessageBox.Show("Hello.")` is highlighted in yellow. At the bottom of the IDE, the Autos, Locals, and Watch windows are docked together on the left side, and the Call Stack, Breakpoints, Exception Settings, Command, Immediate, and Output windows are docked together on the right side.
264+
265+
![Screenshot of breakpoint in the debugger](media/exploreide-debugbreakpoint.png)
246266

247267
6. On the menu bar, choose **Debug** > **Step Out**.
248268

@@ -266,16 +286,10 @@ Now that you've verified that everything works, you can prepare a release build
266286

267287
1. On the main menu, select **Build** > **Clean solution** to delete intermediate files and output files that were created during previous builds. This is not necessary, but it cleans up the debug build outputs.
268288

269-
![The Clean Solution command on the Build menu](../media/exploreide-cleansolution.png)
270-
271289
2. Change the build configuration for HelloWPFApp from **Debug** to **Release** by using the dropdown control on the toolbar (it says "Debug" currently).
272290

273-
![The Standard toolbar with Release selected](../media/exploreide-releaseversion.png)
274-
275291
3. Build the solution by choosing **Build** > **Build Solution**.
276292

277-
![Build Solution command on the Build menu](../media/exploreide-buildsolution.png)
278-
279293
Congratulations on completing this tutorial! You can find the *.exe* you built under your solution and project directory (*...\HelloWPFApp\HelloWPFApp\bin\Release*).
280294

281295
## See also
Binary file not shown.
Binary file not shown.
Loading
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)