Top Related Projects
Sample apps built using the Xamarin.Forms framework
Template Studio accelerates the creation of new WinUI 3, WPF, and UWP apps using a wizard-based experience.
This app demonstrates the controls available in WinUI and the Fluent Design System.
A collection of Flutter examples and demos
Quick Overview
The dotnet/maui-samples repository is a collection of sample projects and applications demonstrating the capabilities of .NET MAUI (Multi-platform App UI). It provides developers with practical examples of how to build cross-platform applications using .NET MAUI for iOS, Android, macOS, and Windows.
Pros
- Comprehensive collection of sample projects covering various MAUI features
- Well-organized and regularly updated to reflect the latest MAUI developments
- Includes both simple examples and more complex, real-world scenarios
- Serves as an excellent learning resource for developers new to MAUI
Cons
- Some samples may not cover all edge cases or advanced scenarios
- Documentation within individual samples can be inconsistent in depth and quality
- May not always keep pace with the rapid development of MAUI itself
- Some samples might be too simplistic for experienced developers seeking advanced techniques
Code Examples
Here are a few short code examples from the repository:
- Creating a simple button with a click event:
Button button = new Button
{
Text = "Click me!",
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center
};
button.Clicked += (sender, args) =>
{
button.Text = "You clicked me!";
};
- Implementing a custom renderer for iOS:
[assembly: ExportRenderer(typeof(MyEntry), typeof(MyEntryRenderer))]
namespace CustomRendererExample.iOS
{
public class MyEntryRenderer : EntryRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if (Control != null)
{
Control.BorderStyle = UITextBorderStyle.None;
}
}
}
}
- Using MVVM pattern with data binding:
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MVVMExample.MainPage">
<StackLayout>
<Entry Text="{Binding Name}" />
<Button Text="Submit" Command="{Binding SubmitCommand}" />
</StackLayout>
</ContentPage>
Getting Started
To get started with the MAUI samples:
-
Clone the repository:
git clone https://github.com/dotnet/maui-samples.git
-
Open the desired sample project in Visual Studio 2022 or Visual Studio for Mac.
-
Ensure you have the .NET MAUI workload installed.
-
Build and run the project on your preferred target platform (iOS, Android, macOS, or Windows).
Competitor Comparisons
Sample apps built using the Xamarin.Forms framework
Pros of xamarin-forms-samples
- More extensive collection of samples, covering a wider range of Xamarin.Forms features
- Longer history and more community contributions
- Includes samples for older Xamarin.Forms versions, useful for maintaining legacy apps
Cons of xamarin-forms-samples
- Based on older technology (Xamarin.Forms), which is being phased out
- May not include the latest cross-platform development features
- Some samples might not be compatible with newer .NET versions
Code Comparison
xamarin-forms-samples:
public class App : Application
{
public App()
{
MainPage = new ContentPage
{
Content = new Label { Text = "Hello, Xamarin.Forms!" }
};
}
}
maui-samples:
public class App : Application
{
public App()
{
MainPage = new ContentPage
{
Content = new Label { Text = "Hello, .NET MAUI!" }
};
}
}
The code structure is similar, reflecting MAUI's evolution from Xamarin.Forms. However, MAUI samples will use newer APIs and features specific to the .NET MAUI framework.
Template Studio accelerates the creation of new WinUI 3, WPF, and UWP apps using a wizard-based experience.
Pros of TemplateStudio
- Broader scope, supporting multiple project types (UWP, WPF, WinUI)
- More comprehensive templates and features for rapid application development
- Active community with frequent updates and contributions
Cons of TemplateStudio
- Less focused on MAUI-specific development
- Steeper learning curve due to its extensive feature set
- May generate more boilerplate code than necessary for simple projects
Code Comparison
MAUI-Samples (MainPage.xaml):
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiApp1.MainPage">
<StackLayout>
<Label Text="Welcome to .NET MAUI!" />
</StackLayout>
</ContentPage>
TemplateStudio (MainPage.xaml):
<Page x:Class="App1.Views.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Style="{StaticResource PageStyle}"
mc:Ignorable="d">
<Grid x:Name="ContentArea">
<!-- Content goes here -->
</Grid>
</Page>
The code comparison shows that MAUI-Samples uses MAUI-specific syntax, while TemplateStudio generates more generic XAML that can be used across different project types.
This app demonstrates the controls available in WinUI and the Fluent Design System.
Pros of WinUI-Gallery
- Focuses specifically on Windows UI development, providing in-depth examples for Windows-specific features
- Offers a comprehensive showcase of WinUI controls and patterns
- Includes XAML and C# code samples directly in the gallery app
Cons of WinUI-Gallery
- Limited to Windows platform, lacking cross-platform support
- Smaller community and ecosystem compared to MAUI
- Less frequent updates and contributions
Code Comparison
WinUI-Gallery (XAML):
<Page
x:Class="AppUIBasics.ControlPages.ButtonPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:AppUIBasics.ControlPages"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
MAUI-Samples (XAML):
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiApp1.MainPage">
<ScrollView>
<VerticalStackLayout Spacing="25" Padding="30,0" VerticalOptions="Center">
The code comparison shows the different namespaces and structure used in WinUI and MAUI XAML files, reflecting their distinct approaches to UI development.
A collection of Flutter examples and demos
Pros of Flutter samples
- More extensive collection of samples covering a wider range of topics and use cases
- Regularly updated with new samples and improvements, reflecting Flutter's rapid development
- Includes complex, real-world app examples like the Gallery app
Cons of Flutter samples
- May be overwhelming for beginners due to the large number of samples
- Some samples might be outdated or not follow the latest best practices
- Less focus on platform-specific features compared to MAUI samples
Code comparison
MAUI sample (C#):
public class MainPage : ContentPage
{
int count = 0;
public MainPage()
{
InitializeComponent();
}
}
Flutter sample (Dart):
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
The MAUI sample uses a more traditional object-oriented approach with a class inheriting from ContentPage
, while the Flutter sample uses a StatefulWidget
with a separate State
class, reflecting Flutter's widget-based architecture.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
.NET MAUI Samples
Samples built with .NET Multi-platform App UI (.NET MAUI).
.NET MAUI is a cross-platform framework for creating mobile and desktop apps with C# and XAML. Using .NET MAUI, you can develop apps that can run on Android, iOS, iPadOS, macOS, and Windows from a single shared codebase.
Official Samples
Official samples can be accessed via the Samples browser.
Sample highlights include:
- .NET eShop Reference Application - "Northern Mountains"
- Point of Sale
- Weather '21 App
- Calculator App
- .NET Podcasts App
- Navigation Samples
- Beginner's Series Task App Sample
Community Samples
.NET MAUI Links
.NET Foundation
There are many .NET related projects on GitHub.
- .NET home repo - links to hundreds of .NET projects, from Microsoft and the community.
- ASP.NET Core home - the best place to start learning about ASP.NET Core.
This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community. For more information, see the .NET Foundation Code of Conduct.
License
.NET (including the maui-samples repo) is licensed under the MIT license.
Top Related Projects
Sample apps built using the Xamarin.Forms framework
Template Studio accelerates the creation of new WinUI 3, WPF, and UWP apps using a wizard-based experience.
This app demonstrates the controls available in WinUI and the Fluent Design System.
A collection of Flutter examples and demos
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot