.NET MAUI Project Templates, Item Templates, and Code Snippets for Visual Studio 2022
Recognized as one of the Top Free Extensions for Visual Studio 2022 by Visual Studio Magazine, an acclaimed tech site.
Stay connected with my Developer Thoughts blog for more insights on .NET MAUI and Blazor.
This VS extension is loaded with Project Templates, Item Templates, and Code Snippets for working with .NET MAUI in Visual Studio 2022.
This has Project Templates for:
- .NET MAUI App - An All-in-One App Project Template - For more details, take a look here
- .NET MAUI Class Library
- Shared Class Library (Xamarin.Forms and .NET MAUI)
And Item Templates for:
ContentPage and ContentView, in XAML, C#, and Razor.
Shell Page for defining app visual hierarchy in XAML, C#, and Razor.
Resource Dictionary for managing resources in XAML.
- Generic Item
- Generic Item (C#)
- Content Page
- Content Page (C#)
- Content Page (Razor)
- Content Page with BlazorWebView
- Content Page with BlazorWebView (C#)
- Content Page with ViewModel
- Content Page (C#) with ViewModel
- Content View
- Content View (C#)
- Content View (Razor)
- Resource Dictionary
- Resource Dictionary (XAML only)
- Shell Page
- Shell Page (C#)
- Shell Page (Razor)
- Custom View and Handler (Regular)
- Handler definitions generated in the Platforms folder
- Custom View and Handler (Cond.)
- Handler definitions are generated in the same folder in a conditional compilation format
- Custom View and Renderer (Regular)
- Renderer definitions generated in the Platforms folder
- Custom View and Renderer (Cond.)
- Renderer definitions generated in the same folder in a conditional compilation format
- Comet Page (C#)
- Partial Class (C#)
- Made available in the section titled
Code
- For the Cond. type template to work properly, ensure Conditional Compilation is enabled as mentioned in detail here
C# and XAML Code Snippets
Note: Currently, the project templates target .NET MAUI 6/7/8 GA, Service Releases, .NET 9 Previews, and Nightly Builds (VS2022 17.3.0 or higher (including Previews)), and to support further changes in newer .NET MAUI releases, an update to this VS extension will be made available accordingly.
Version History (latest on top):
- .NET MAUI workload is now a prerequisite for installing this extension (As of now this is tested to work on VS2022 17.3.0 or a later version).
5.2.1.0:
- Templates updated for the latest .NET MAUI release
- The
.NET MAUI Community Toolkit
package version bumped to reference the latest release
5.1.0.0:
- Templates updated for the latest .NET MAUI release
- The MauiVersion property is updated to dynamically refer to the latest available service release (
8.*
)
- Auto inclusion of
.NET MAUI Community Toolkit
's xml namespace while using NET MAUI Generic item template with its type name defined with scope as mct:
5.0.0.1:
- Support for creating
.NET MAUI
projects on .NET 9
Previews
- On the stable channel, the value of the MauiVersion property is bumped to 8.0.7 to support the latest version of
.NET MAUI 8 SR2
NuGet packages
- For more details, check this article
4.9.0.0:
- A revolutionary generic item template, in XAML and C#, for creating items of any type
- Both need one required parameter, the Base type
- And optionally takes another parameter, to specify the Generic base type
- In addition, the XAML template takes one more parameter (Xaml Only), to generate only the XAML definition
- Frequently used base types are loaded in the Editable dropdown, user can also enter their value here
- Ensure the values are entered in Pascal notation. XAML templates support XML namespace prefix, quite like how it is used in the real world (
mct:Popup
)
- The one big advantage of using this on IDE is the relative namespace to the folder where the item is created whereas on CLI, this defaults to the root namespace
- Note: Namespace resolution in both XAML and C# files is left to the user as deriving them with the template is outside its scope.
- Tip: For the XAML template, pass the
xmlns
scope as part of the input parameter value and it'll be used appropriately in the generated source files
- Tip: Use
local
scope to refer to the types in the same directory like Views
. For example, local:BasePage
4.8.1.0:
- Defined MauiVersion property (with its value set to
8.0.6
) in the .NET 8 stable template to support .NET MAUI 8 SR1
- For more details, check this article
4.7.0.0:
- Xamarin.Forms Target Framework option in Shared Class Library project template
- Supported values are:
.NET Standard 2.0
(default value) and .NET Standard 2.1
- And for .NET MAUI via the Framework option
- Supported values are:
.NET 8
(default value), .NET 7
, and .NET 6
4.6.0.0:
- Added the option to reference Nightly build MAUI packages (from the CI feed) in all the supported templates.
Note: For this work, add the following URL as a NuGet package source and more details here:
dotnet nuget add source -n maui-nightly https://aka.ms/maui-nightly/index.json
4.5.0.0:
- MAUI Community Toolkit package versions bumped to their latest versions supporting the .NET 8 release
- Option to reference the Shared Toolkit NuGet package in all of the templates
4.4.0.0:
- Templates updated for .NET 8 RTM
- Incorporated .NET 8 / C# 12 features wherever possible
- .NET MAUI Version on the Main page of the App
4.3.6.0:
- Defined custom logic for BlazorWebView XAML item template processing
4.3.0.0:
- Templates updated for .NET 8 RC2
4.2.2.0:
4.2.1.0:
- Support for Blazor Hybrid in F# project template. Added the
Application Design
parameter for this.
- This takes two options, Plain and Hybrid. The default value is Plain.
Note: The RCL project in the F# template is C# based as Razor compilation is not working with F# as expected.
- Option to include reference Shared Toolkit while creating the Shared Class Library project.
- .NET MAUI Community Toolkit package versions bumped to their latest versions.
4.1.0.0:
- Templates updated for .NET 8 RC1
- Project file enhancements
- The default value for the Framework parameter is now updated as net8.0
4.0.1.0:
4.0.0.0:
- .NET MAUI App
F#
project template with Fabulous
- Not all options in the
C#
template are supported in the F#
template