• Stars
    star
    474
  • Rank 92,640 (Top 2 %)
  • Language
    C#
  • License
    MIT License
  • Created over 3 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The .NET MAUI Markup Community Toolkit is a community-created library that contains Fluent C# Extension Methods to easily create your User Interface in C#

.NET MAUI Community Toolkit bot .NET Foundation

Build Status NuGet

.NET MAUI Markup Community Toolkit

The .NET MAUI Markup Community Toolkit is a collection of Fluent C# Extension Methods that allows developers to continue architecting their apps using MVVM, Bindings, Resource Dictionaries, etc., without the need for XAML

All features are contributed by you, our amazing .NET community, and maintained by a core set of maintainers.

And – the best part – the features you add to the .NET MAUI Toolkit may one day be included into the official .NET MAUI library! We leverage the Community Toolkits to debut new features and work closely with the .NET MAUI engineering team to nominate features for promotion.

Getting Started

In order to use the .NET MAUI Community Toolkit you need to call the extension method in your MauiProgram.cs file as follows:

using CommunityToolkit.Maui.Markup;

public static MauiApp CreateMauiApp()
{
    var builder = MauiApp.CreateBuilder();
    // Initialise the toolkit
    builder.UseMauiApp<App>().UseMauiCommunityToolkitMarkup();
    // the rest of your logic...
}

Documentation

image

All of the documentation for CommunityToolkit.Maui.Markup can be found here on Microsoft Learn:

https://learn.microsoft.com/dotnet/communitytoolkit/maui/markup/markup

Examples

Here are some brief examples showing how common tasks can be achieved through the use of the Markup package.

Bindings

C# Markup allows us to define the binding fluently and therefore chain multiple methods together to reduce the verbosity of our code:

new Entry()
    .Bind(Entry.TextProperty, static (ViewModel vm) => vm.RegistrationCode);

For further details on the possible options for the Bind method refer to the BindableObject extensions documentation.

Sizing

Markup allows us to define the sizing fluently and therefore chain multiple methods together to reduce the verbosity of our code:

new Entry().Size(200, 40);

For further details on the possible options for the Size method refer to the VisualElement extensions documentation.

In-depth example

This example creates a Grid object, with child Label and Entry objects. The Label displays text, and the Entry data binds to the RegistrationCode property of the viewmodel. Each child view is set to appear in a specific row in the Grid, and the Entry spans all the columns in the Grid. In addition, the height of the Entry is set, along with its keyboard, colors, the font size of its text, and its Margin.

C# Markup extensions also allow developers to define names for Columns and Rows (e.g. Column.Input) using an enum.

C# Markup enables this to be defined using its fluent API:

using static CommunityToolkit.Maui.Markup.GridRowsColumns;

class SampleContentPage : ContentPage
{
    public SampleContentPage()
    {
        Content = new Grid
        {
            RowDefinitions = Rows.Define(
                (Row.TextEntry, 36)),

            ColumnDefinitions = Columns.Define(
                (Column.Description, Star),
                (Column.Input, Stars(2))),

            Children =
            {
                new Label()
                    .Text("Code:")
                    .Row(Row.TextEntry).Column(Column.Description),

                new Entry
                {
                    Keyboard = Keyboard.Numeric,
                    BackgroundColor = Colors.AliceBlue,
                }.Row(Row.TextEntry).Column(Column.Input)
                 .FontSize(15)
                 .Placeholder("Enter number")
                 .TextColor(Colors.Black)
                 .Height(44)
                 .Margin(5, 5)
                 .Bind(Entry.TextProperty, static (ViewModel vm) vm => vm.RegistrationCode)
            }
        };
    }

    enum Row { TextEntry }
    enum Column { Description, Input }
}

Submitting A New Feature

New features will follow this workflow, described in more detail in the steps below

New Feature Workflow

1. Discussion Started

Debate pertaining to new Maui Toolkit features takes place in the form of Discussions in this repo.

If you want to suggest a feature, discuss current design notes or proposals, etc., please open a new Discussion topic.

Discussions that are short and stay on topic are much more likely to be read. If you leave comment number fifty, chances are that only a few people will read it. To make discussions easier to navigate and benefit from, please observe a few rules of thumb:

  • Discussion should be relevant to the .NET MAUI Toolkit. If they are not, they will be summarily closed.
  • Choose a descriptive topic that clearly communicates the scope of discussion.
  • Stick to the topic of the discussion. If a comment is tangential, or goes into detail on a subtopic, start a new discussion and link back.
  • Is your comment useful for others to read, or can it be adequately expressed with an emoji reaction to an existing comment?

2. Proposal Submitted

Once you have a fully fleshed out proposal describing a new feature in syntactic and semantic detail, please open an issue for it, and it will be labeled as a Proposal. The comment thread on the issue can be used to hash out or briefly discuss details of the proposal, as well as pros and cons of adopting it into the .NET MAUI Toolkit. If an issue does not meet the bar of being a full proposal, we may move it to a discussion, so that it can be further matured. Specific open issues or more expansive discussion with a proposal will often warrant opening a side discussion rather than cluttering the comment section on the issue.

3. Proposal Championed

When a member of the .NET MAUI Toolkit core team finds that a proposal merits promotion into the Toolkit, they can Champion it, which means that they will bring it to the monthly .NET MAUI Toolkit Community Standup.

4. Proposal Approved

The .NET MAUI Toolkit core team will collectively vote to work on adopting and/or modifying the proposal, requiring a majority approval (i.e. greater than 50%) to be added to the Toolkit.

Once a Proposal has been championed and has received a majority approval from the .NET MAUI Toolkit core team, a Pull Request can be opened.

5. Pull Request Approved

After a Pull Request has been submitted, it will be reviewed and approved by the Proposal Champion.

Every new feature also requires an associated sample to be added to the .NET MAUI Toolkit Sample app.

6. Documentation Complete

Before a Pull Request can be merged into the .NET MAUI Toolkit, the Pull Request Author must also submit the documentation to our documentation repository.

7. Merged

Once a Pull Request has been reviewed + approved AND the documentation has been written, submitted and approved, the new feature will be merged adding it to the .NET MAUI Toolkit

Code of Conduct

As a part of the .NET Foundation, we have adopted the .NET Foundation Code of Conduct. Please familiarize yourself with that before participating with this repository. Thanks!

.NET Foundation

This project is supported by the .NET Foundation.

More Repositories

1

WindowsCommunityToolkit

The Windows Community Toolkit is a collection of helpers, extensions, and custom controls. It simplifies and demonstrates common developer tasks building .NET apps with UWP and the Windows App SDK / WinUI 3 for Windows 10 and Windows 11. The toolkit is part of the .NET Foundation.
C#
5,887
star
2

dotnet

.NET Community Toolkit is a collection of helpers and APIs that work for all .NET developers and are agnostic of any specific UI platform. The toolkit is maintained and published by Microsoft, and part of the .NET Foundation.
C#
3,007
star
3

Maui

The .NET MAUI Community Toolkit is a community-created library that contains .NET MAUI Extensions, Advanced UI/UX Controls, and Behaviors to help make your life as a .NET MAUI developer easier
C#
2,203
star
4

MVVM-Samples

Sample repo for MVVM package
1,129
star
5

Lottie-Windows

Lottie-Windows is a library (and related tools) for rendering Lottie animations on Windows 10 and Windows 11.
C#
627
star
6

Windows

Collection of controls for WinUI 2, WinUI 3, and Uno Platform developers. Simplifies and demonstrates common developer tasks building experiences for Windows with .NET.
C#
538
star
7

Microsoft.Toolkit.Win32

ARCHIVE - This repository contained XAML Islands wrapper controls and tooling for XAML Islands with WinUI 2, see readme for more info about XAML Islands with WinUI 3 and the WindowsAppSDK.
C#
381
star
8

Labs-Windows

A safe space to collaborate and engineer solutions from the prototyping stage all the way through polished finalized component for the Windows Community Toolkit.
C#
324
star
9

ColorCode-Universal

This is a port of ColorCode to .NET Standard. The original Html only formatter has been separated from the Logic, so now it can produce Syntax Highlighted code for any output. This Project can currently produce HTML, and Render to UWP RichTextBlocks.
C#
216
star
10

Maui.NativeLibraryInterop

Maui.NativeLibraryInterop is a community-created library of binding samples to help .NET MAUI developers interop with native libraries more easily
C#
170
star
11

Graph-Controls

Set of Helpers and Controls for Windows development using the Microsoft Graph.
C#
155
star
12

Datasync

A collection of libraries that implement a client-server system used for synchronizing data from a cloud-based database.
C#
45
star
13

SceneLoader

A library for creating 3D Windows.UI.Composition.Scenes from glTF.
C#
36
star
14

Tooling-Windows-Submodule

Community Toolkit infrastructure for use as a submodule 'tooling' directory in other repositories.
C#
30
star
15

Sample-TabView-TearOff

Sample demonstrating using the TabView UWP control in the Windows Community Toolkit and Windows Template Studio's Multiple View feature to 'tear-off' tabs to create windows and drag them between windows.
C#
27
star
16

Labs-IntelligentAPIs

Intelligent APIs aim to make machine learning (ML) tasks easier for UWP developers to leverage in their applications without needing ML expertise or creating a new model.
C#
21
star
17

announcements

Subscribe to this repo to be notified of Announcements and changes in the Windows Community Toolkit
13
star
18

Sample-Graph-ContosoNotes

A simple note taking app infused with the power of Microsoft Graph and built with the Windows Community Toolkit!
C#
13
star
19

design-assets

Windows Community Toolkit design guide and templates
10
star
20

PWAWindowsHelpers

Helpers for Progressive Windows Apps running on Windows
JavaScript
9
star
21

WindowsCommunityToolkit-wiki

Wiki fork for main WindowsCommunityToolkit repo with project Documentation and Guidance
8
star
22

github-bot-uwp-toolkit

GitHub bot for the UWP Community Toolkit project to manage issues and Pull Requests
TypeScript
7
star
23

ToolkitLabs.dev

Repository for https://toolkitlabs.dev/ site
JavaScript
6
star
24

Labs-GazeControls

Set of user controls that can be reused in different applications with eye gaze input.
C#
6
star
25

Sample-Windows-CppWinRT

Sample which demonstrates using the Windows Community Toolkit within a C++/WinRT UWP application
C++
5
star
26

ReleaseNotesGenerator

dotnet core console app that generates release notes from pull requests for the UWP Community Toolkit
C#
4
star