Skip to content

C# Code Markup Library for WinUI 3: User Interface Development with Fluent Methods

License

Notifications You must be signed in to change notification settings

idexus/CodeMarkup-WinUI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

89 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

CodeMarkup for WinUI enables you to build user interfaces declaratively in C# code using fluent methods. With this library, you can create interfaces without the need for XAML.

Hot Reload Support

Example Page

using Windows.UI;
using Microsoft.UI;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Data;

namespace ExampleApp
{
    using CodeMarkup.WinUI;

    [Bindable]
    public partial class HomePage : Page
    {
        int count = 0;

        public HomePage()
        {
            this.Resources = new()
            {
                new ThemeValue<Color> { Key = "HeaderColor", Light = Colors.Navy, Dark = Colors.Aqua }
            };

            this.VerticalAlignment = VerticalAlignment.Center;

            Content = new StackPanel
            {
                new TextBlock()
                    .FontSize(45)
                    .Text("Code Markup for WinUI")
                    .TextAlignment(TextAlignment.Center)
                    .Foreground(e => e.ResourceKey("HeaderColor").Source(this)),

                new TextBlock()
                    .FontSize(20)
                    .Text("Welcome to the Quick Samples Gallery")
                    .TextAlignment(TextAlignment.Center),

                new Button()
                    .Content("Click me")
                    .Margin(0,35,0,15)
                    .FontSize(20)
                    .HorizontalAlignment(HorizontalAlignment.Center)
                    .OnClick(button =>
                    {
                        count++;
                        button.Content = $"Clicked {count} ";
                        button.Content += count == 1 ? "time" : "times";
                    })
            };
        }
    }
}

Nuget

In Your Project

CodeMarkup for WinUI replaces some standard WinUI classes by subclassing them and adding new constructors and IEnumerable interface implementation. To use CodeMarkup controls in your projects, you need to include the using CodeMarkup.WinUI statement inside your app namespace.

using Windows.UI;
using Microsoft.UI;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Data;

namespace ExampleApp;
using CodeMarkup.WinUI;

...

Or:

using Windows.UI;
using Microsoft.UI;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Data;

namespace ExampleApp
{
    using CodeMarkup.WinUI;
    ...
}

Disclaimer

CodeMarkup for WinUI is a proof of concept. There is no official support. Use at your own risk.

License

The MIT License, Copyright (c) 2023 Pawel Krzywdzinski

About

C# Code Markup Library for WinUI 3: User Interface Development with Fluent Methods

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages