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
Copy file name to clipboardExpand all lines: hub/apps/windows-dotnet-maui/index.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,7 +49,7 @@ This [one-day live stream](https://www.youtube.com/playlist?list=PLdo4fOcmZ0oWeP
49
49
### .NET MAUI blog posts
50
50
51
51
-[5 .NET MAUI Features for Building Great Desktop Apps](https://devblogs.microsoft.com/dotnet/5-dotnet-maui-desktop-features/)
52
-
-[Build Your Own Podcast App with .NET 7, Blazor, and .NET MAUI](https://devblogs.microsoft.com/dotnet/build-your-own-podcast-app-with-dotnet-blazor-and-dotnet-maui/)
52
+
-[Build Your Own Podcast App with .NET, Blazor, and .NET MAUI](https://devblogs.microsoft.com/dotnet/build-your-own-podcast-app-with-dotnet-blazor-and-dotnet-maui/)
description: Get hands-on with .NET MAUI by building your first cross-platform app on Windows.
4
-
ms.topic: article
5
-
ms.date: 08/15/2022
4
+
ms.topic: how-to
5
+
ms.date: 01/23/2025
6
6
keywords: windows win32, desktop development, Windows App SDK, .net maui
7
7
ms.localizationpriority: medium
8
+
#Customer intent: As a Windows developer, I want to learn how to create and run my first .NET MAUI app for Windows in Visual Studio.
8
9
---
9
10
10
11
# Build your first .NET MAUI app for Windows
@@ -23,29 +24,29 @@ If you haven't already set up your environment for .NET MAUI development, please
23
24
24
25
1. Launch Visual Studio, and in the start window click **Create a new project** to create a new project:
25
26
26
-

27
+

27
28
28
-
2. In the **Create a new project** window, select **MAUI** in the All project types drop-down, select the **.NET MAUI App** template, and click the **Next** button:
29
+
1. In the **Create a new project** window, select **MAUI** in the All project types drop-down, select the **.NET MAUI App** template, and click the **Next** button:
3. In the **Configure your new project** window, give your project a name, choose a location for it, and click the **Next** button:
33
+
1. In the **Configure your new project** window, give your project a name, choose a location for it, and click the **Next** button:
33
34
34
-

35
+

35
36
36
-
4. In the **Additional information** window, click the **Create** button:
37
+
1. In the **Additional information** window, click the **Create** button:
37
38
38
-

39
+

39
40
40
-
5. Wait for the project to be created, and for its dependencies to be restored:
41
+
1. Wait for the project to be created, and for its dependencies to be restored:
41
42
42
-

43
+

43
44
44
-
6. In the Visual Studio toolbar, press the Windows Machine button to build and run the app.
45
+
1. In the Visual Studio toolbar, press the Windows Machine button to build and run the app.
45
46
46
-
7. In the running app, press the **Click me** button several times and observe that the count of the number of button clicks is incremented:
47
+
1. In the running app, press the **Click me** button several times and observe that the count of the number of button clicks is incremented:
47
48
48
-

49
+

49
50
50
51
You just ran your first .NET MAUI app on Windows. In the next section, you'll learn how to add data binding and messaging features from the **MVVM Toolkit** to your app.
51
52
@@ -59,116 +60,117 @@ Now that you have your first .NET MAUI app running on Windows, let's add some MV
59
60
60
61
1. Right-click the project in **Solution Explorer** and select **Manage NuGet Packages...** from the context menu.
61
62
62
-
2. In the **NuGet Package Manager** window, select the **Browse** tab and search for **CommunityToolkit.MVVM**:
63
+
1. In the **NuGet Package Manager** window, select the **Browse** tab and search for **CommunityToolkit.MVVM**:
7. The `MainViewModel` class will be the data binding target for the `MainPage`. Update it to inherit from `ObservableObject` in the `CommunityToolkit.Mvvm.ComponentModel` namespace This will also require updating the class to be `public` and `partial`.
77
+
1. The `MainViewModel` class will be the data binding target for the `MainPage`. Update it to inherit from `ObservableObject` in the `CommunityToolkit.Mvvm.ComponentModel` namespace This will also require updating the class to be `public` and `partial`.
77
78
78
-
8. The `MainViewModel` class will contain the following code. The `CountChangedMessage` record defines a message that is sent each time the Click me button is clicked, notifying the view of the change. The [ObservableProperty](/dotnet/communitytoolkit/mvvm/generators/observableproperty) and [RelayCommand](/dotnet/communitytoolkit/mvvm/generators/relaycommand) attributes added to the `message` and `IncrementCounter` members are source generators provided by the MVVM Toolkit to create the MVVM boilerplate code for `INotifyPropertyChanged` and `IRelayCommand` implementations. The `IncrementCounter` method's implementation contains the logic from `OnCounterClicked` in MainPage.xaml.cs, with a change to send a message with the new counter message. We will be removing that code-behind code later.
79
+
1. The `MainViewModel` class will contain the following code. The `CountChangedMessage` record defines a message that is sent each time the Click me button is clicked, notifying the view of the change. The [ObservableProperty](/dotnet/communitytoolkit/mvvm/generators/observableproperty) and [RelayCommand](/dotnet/communitytoolkit/mvvm/generators/relaycommand) attributes added to the `message` and `IncrementCounter` members are source generators provided by the MVVM Toolkit to create the MVVM boilerplate code for `INotifyPropertyChanged` and `IRelayCommand` implementations. The `IncrementCounter` method's implementation contains the logic from `OnCounterClicked` in MainPage.xaml.cs, with a change to send a message with the new counter message. We will be removing that code-behind code later.
10. Add the following code to the `MainPage` constructor after the call to `InitializeComponenent()`. This code will receive the message sent by `IncrementCounter()` in the `MainViewModel` and will update the `CounterBtn.Text` property with the new message and announce the new text with the `SemanticScreenReader`:
14. Update the `Button` on `MainPage` to use a `Command` instead of handling the `Clicked` event. The command will bind to the `IncrementCounterCommand` public property that is generated by the MVVM Toolkit's source generators:
16. While the project is running, try updating the "Hello, World!" message in the first Label to read "Hello, Windows!" in **MainPage.xaml**. Save the file and notice that [XAML Hot Reload](/dotnet/maui/xaml/hot-reload) updates the UI while the app is still running:
Learn to build an app that displays [Microsoft Graph](/graph/) data for a user by leveraging the [Graph SDK](/graph/sdks/sdks-overview) in a [.NET MAUI for Windows tutorial](./tutorial-graph-api.md).
170
+
Learntobuildanappthatdisplays [MicrosoftGraph](/graph/) datafor a user by leveraging the [Graph SDK](/graph/sdks/sdks-overview) ina [.NETMAUIforWindowstutorial](tutorial-graph-api.md).
0 commit comments