Top Related Projects
Samples for .NET Multi-Platform App UI (.NET MAUI)
A curated list of awesome Xamarin.Forms libraries and resources
Quick Overview
Xamarin.Forms-Samples is a GitHub repository containing a comprehensive collection of sample applications and code snippets for Xamarin.Forms. It serves as a valuable resource for developers learning to build cross-platform mobile applications using C# and .NET, showcasing various features and best practices of Xamarin.Forms.
Pros
- Extensive collection of samples covering a wide range of Xamarin.Forms features
- Well-organized and regularly updated with new samples and improvements
- Includes both simple examples and more complex, real-world scenarios
- Provides a practical learning resource for developers of all skill levels
Cons
- Some samples may become outdated as Xamarin.Forms evolves
- Not all samples may follow the latest best practices or design patterns
- The repository's size might be overwhelming for beginners
- Some advanced topics may require additional documentation or explanation
Code Examples
- Basic XAML UI example:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="SampleApp.MainPage">
<StackLayout>
<Label Text="Welcome to Xamarin.Forms!"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand" />
</StackLayout>
</ContentPage>
- Data binding example:
public class ViewModel : INotifyPropertyChanged
{
private string _name;
public string Name
{
get => _name;
set
{
_name = value;
OnPropertyChanged();
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
- Navigation example:
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
async void OnButtonClicked(object sender, EventArgs e)
{
await Navigation.PushAsync(new DetailPage());
}
}
Getting Started
To get started with Xamarin.Forms-Samples:
- Clone the repository:
git clone https://github.com/xamarin/xamarin-forms-samples.git
- Open the solution file of the desired sample in Visual Studio or Visual Studio for Mac
- Restore NuGet packages and build the solution
- Run the sample on your preferred platform (iOS, Android, or UWP)
For more detailed instructions, refer to the README.md file in the repository root or the individual sample folders.
Competitor Comparisons
Samples for .NET Multi-Platform App UI (.NET MAUI)
Pros of maui-samples
- More modern and future-proof, as .NET MAUI is the successor to Xamarin.Forms
- Supports a wider range of platforms, including Windows and macOS
- Improved performance and reduced app size due to .NET 6+ optimizations
Cons of maui-samples
- Newer technology with potentially fewer community resources and third-party libraries
- May require learning new concepts and migration for developers familiar with Xamarin.Forms
- Some features and controls might not be fully mature compared to Xamarin.Forms
Code Comparison
xamarin-forms-samples:
public App()
{
InitializeComponent();
MainPage = new NavigationPage(new MainPage());
}
maui-samples:
public App()
{
InitializeComponent();
MainPage = new AppShell();
}
The main difference in the code snippets is the use of AppShell
in .NET MAUI, which provides a more flexible navigation structure compared to the traditional NavigationPage
in Xamarin.Forms. This reflects MAUI's enhanced navigation capabilities and modern app architecture approach.
Both repositories offer extensive sample projects demonstrating various features and best practices for their respective frameworks. While xamarin-forms-samples provides a wealth of established patterns, maui-samples showcases the latest cross-platform development techniques and UI components available in .NET MAUI.
A curated list of awesome Xamarin.Forms libraries and resources
Pros of awesome-xamarin-forms
- Curated list of resources, libraries, and tools for Xamarin.Forms development
- Regularly updated with community contributions
- Covers a wide range of topics, including UI controls, animations, and best practices
Cons of awesome-xamarin-forms
- Lacks actual code samples or projects
- May require additional research to implement specific features
- Not officially maintained by the Xamarin team
Code Comparison
xamarin-forms-samples:
public class App : Application
{
public App()
{
MainPage = new ContentPage
{
Content = new StackLayout
{
Children = {
new Label { Text = "Welcome to Xamarin.Forms!" }
}
}
};
}
}
awesome-xamarin-forms:
No direct code samples available. Instead, it provides links to various resources and libraries, such as:
- UI Controls: Syncfusion Essential UI Kit for Xamarin.Forms
- Animations: Lottie Xamarin
- MVVM Frameworks: FreshMvvm
While xamarin-forms-samples offers practical code examples, awesome-xamarin-forms serves as a comprehensive directory of resources for Xamarin.Forms developers. The choice between the two depends on whether you need hands-on code samples or a curated list of tools and libraries to enhance your Xamarin.Forms development experience.
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
Xamarin.Forms code samples
The samples in this repository demonstrate how to use different aspects of Xamarin.Forms to build cross-platform apps for iOS, Android, and the Universal Windows Platform (UWP). Please visit Microsoft code sample browser to download individual samples.
For additional platform support, visit the following forks:
- Tizen: https://github.com/Samsung/xamarin-forms-samples
- GTK#: https://github.com/jsuarezruiz/xamarin-forms-samples/tree/gtk
License
See the license file and any additional license information attached to each sample.
Sample submission guidelines
This repository welcomes contributions and suggestions. If you want to create a new sample, you need to work with an employee to help bring the new sample into the repository. Start by raising a GitHub issue in this repository that outlines your proposed sample. Please note that samples in the master
branch of this repository shouldn't rely on preview or pre-release NuGet packages.
The Xamarin.Forms samples in the Microsoft samples browser are sourced from this repository. Samples need to comply with the following requirements:
-
Screenshots - a folder called Screenshots that has at least one screen shot of the sample on each platform (preferably a screen shot for every page or every major piece of functionality). For an example of this, see TodoREST.
-
Readme - a
README.md
file that explains the sample, and contains metadata to help customers find it. For an example of this, see WebServices/TodoREST. The README file should begin with a YAML header (delimited by---
) with the following keys/values:-
name - must begin with
Xamarin.Forms -
-
description - brief description of the sample (< 150 chars) that appears in the sample code browser search
-
page_type - must be the string
sample
. -
languages - coding language/s used in the sample, such as:
csharp
,fsharp
,vb
,java
-
products: should be
xamarin
for every sample in this repo -
urlFragment: although this can be auto-generated, please supply a value that represents the sample's path in this repo, except directory separators are replaced with dashes (
-
).
Here is a working example from WebServices/TodoREST README raw view.
--- name: Xamarin.Forms - TodoREST description: This sample demonstrates a Todo list application where the data is stored and accessed from a RESTful web service. page_type: sample languages: - csharp products: - xamarin urlFragment: webservices-todorest --- # Heading 1 rest of README goes here, including screenshot images and requirements/instructions to get it running
NOTE: This must be valid YAML, so some characters in the name or description will require the entire string to be surrounded by " or ' quotes.
-
-
-
Buildable solution and .csproj file - the project must build and have the appropriate project scaffolding (solution + .csproj files).
This approach ensures that all samples integrate with the Microsoft sample code browser.
If you have any questions, create an issue or ask on the Xamarin Forums.
Top Related Projects
Samples for .NET Multi-Platform App UI (.NET MAUI)
A curated list of awesome Xamarin.Forms libraries and resources
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