Home

Awesome

SharpConstraintLayout 🗜️📏

This is a C# port of ConstraintLayout, it convert constraintlayout.core and create ConstraintLayout for dotnet UI framework. Now, you can use ConstraintLayout in C# world 🎆

NuGet version(SharpConstraintLayout.Core), it contain core logic of constraintlayout, you can base on it create your ConstraintLayout for other dotnet UI framework.

NuGet version(SharpConstraintLayout.Maui), it contain layout for Maui, ConstraintLayout is powerful, you can use it instead other layout

Notice:I stop update SharpConstraintLayout.Maui.Native, because dealing with difference of different platform is tiresome.

NuGet version(SharpConstraintLayout.Maui.Native), it contain layout for net6-android,net6-ios,winui3, such as at android, you can use it instead Xamarin.AndroidX.ConstraintLayout

Using SharpConstraintLayout

Document see wiki

Maui SharpConstraintLayout Example

Installation

Search and install nuget SharpConstraintLayout.Maui (For Maui) or SharpConstraintLayout.Maui.Native (For net6-android,net6-ios,WinUI3)

Notice

  1. Now you create constraint only by code.
  2. Here all example use Maui
  3. Run example app, you can find more example

Basis Align First you need create layout and add controls to layout,

var layout = new ConstraintLayout();
var firstButton = new Button(){ Text = "first"};
var secondButton = new Button(){ Text = "second"};
layout.AddElement(firstButton,secondButton)

then set first button at center of layout.

using(var set = FluentConstraintSet())
{
  set.Clone(layout);
  set.Select(firstButton).CenterTo()
  set.ApplyTo(layout);
}

or you can set second button align first button

using(var set = FluentConstraintSet())
{
  set.Clone(layout);
  set.Select(firstButton).CenterTo()
  .Select(secondButton).LeftToRight(firstButton).CenterYTo(firstButton)
  set.ApplyTo(layout);
}

Current Features

💻 Authors of ConstraintLayout

See also the list of contributors who participated in this project.

🔖 License

This project is licensed under the Apache 2.0 License - see the LICENSE file for details