Skip to content

Latest commit

 

History

History
107 lines (82 loc) · 2.79 KB

README.md

File metadata and controls

107 lines (82 loc) · 2.79 KB

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