A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/VincentH-Net/CSharpForMarkup below:

GitHub - VincentH-Net/CSharpForMarkup: Concise, declarative C# UI markup for .NET browser

Concise next-gen C# Markup for .NET UI frameworks

C# Markup 2 for Uno Platform

C# Markup 2 supports multiple UI frameworks, including the excellent Uno Platform.

If you don't know Uno, I recommend you check them out; Uno is one of the best and most mature .NET UI frameworks, it offers an impressive breadth of features that will have your back when you need to create real-world production apps end2end, fast.

dotnet new install Uno.Templates
dotnet new install Modern.CSharp.Templates

md UnoCSharpMarkup2
cd UnoCSharpMarkup2

dotnet new unoapp -preset recommended
dotnet new mcs-uno-markup2 --presentation mvux --renderer skia --allow-scripts yes
Markup options at a glance - good for everyone!

Uno Platform supports both XAML and C# UI with Uno C# Markup. C# Markup 2 adds another option that goes above and beyond what gen-1 C# Markup variants offer.

It's good to have options - everyone wins: devs get the experience that they like best, and the UI framework gains more adoption. Check it out and pick what you like!

As a first impression, here's a quick side-by-side comparison:

Enjoy a Flutter-like UI development experience with C# Markup 2:

No XAML / HTML / JavaScript / CSS required. No engine or layers to get in your way.

NuGet








Chat (if needed, join DotNetEvolution first)

The best place to ask questions or help!

Looking for C# Markup 1? Find it here

July 14, 2025

Mapsui 5 - currently in beta, and one of the best OSS .NET libraries for maps - now has full support in C# Markup 3.1 for Uno Platform 6.0!

An example page using Mapsui is added to the example app in this repo, demonstrating how to use Mapsui with C# Markup 2. Browse Live Mapsui 5.0 samples to experience the possibilities; see the samples source for how.

July 4, 2025

ScottPlot 5 support added!

ScottPlot.NET - one of the best OSS .NET libraries for graphs and charts - now has full support in C# Markup 3.1 for Uno Platform 6.0!

An example page using ScottPlot is added to the example app in this repo, demonstrating how to use ScottPlot with C# Markup 2. Use the excellent ScottPlot 5.0 Cookbook to create beautiful graphs!

May 12, 2025

New C# Markup 3.1 for Uno Platform 6.0

Hot on the heels of the game-changing Uno 6.0 release, today's release adds full support for Uno SDK 6.0 / Windows App SDK 1.7 to all CSharpMarkup.WinUI NuGets.

Includes support for all API improvements in Uno SDK 6.0:

The example app in the repo is also updated to Uno 6.0 / Windows App SDK 1.7.

May 5, 2025

New C# Markup 3.0 for Uno Platform 5.6 and .NET 9

Today's release adds full support for Uno SDK 5.6 / Windows App SDK 1.6 and .NET 9 / .NET 8 to all CSharpMarkup.WinUI NuGets.

Includes support for all improvements in Uno SDK 5.6:

The example app in the repo is also updated to .NET 9 plus Uno 5.6 / Windows App SDK 1.6 and demonstrates how to use C# partial properties with MVVM Community Toolkit to support AOT.

May 7, 2024

New C# Markup 2.4 for Uno Platform 5.2 incl .NET Single Project

Today's release is fully updated to Updated to Uno 5.2 including Uno's .NET Single Project and uno.sdk!

Plus:

Dec 21, 2023

New C# Markup 2 templates for Uno Platform 5

In addition to some new C# Markup 2 methods, today's release adds support for the new C# Markup 2 templates for Uno Platform 5: an updated mcs-uno-markup2 template, and a new mcs-uno-view template.

Nov 18, 2023

2.3 Release is GA - adds support for .NET 8, Uno 5 plus 5 Uno Libraries!

This release is fully updated to the awesome Uno 5 release and .NET 8 GA. You can use the Uno Solution Wizard for Visual Studio and add a C# Markup 2 project to it at any time with one command. All Uno wizard customizations are supported: combine C# Markup 2 with MVUX or MVVM, XAML or Uno C# Markup, use Uno Navigation extensions, and target .NET 8 or .NET 7. All Uno target platforms are supported.

A brand new dotnet new C# Markup 2 project template gets you going in no time - carefully optimized for an optimal developer experience: uncluttered solution explorer view, automatic file grouping of markup and logic files, uncluttered markup source, focused intellisense, clear starting points for markup extensions in your code, plus fast hot reload - both automatic and with a hot reload button overlay in debug mode, for the platforms that your IDE can hot reload but cannot (yet) update the UI automatically.

Enjoy general C# Markup 2 improvements, plus C# Markup 2 API's for 5 additional Uno libraries:

The getting started is fully up to date. Examples in this repo and this readme will be updated soon to show off the new features.

NJoy concise C# Markup!

Nov 1, 2023

2.3 Preview Release adds 5 Uno Libraries!

Enjoy general C# Markup 2 improvements, plus C# Markup 2 API's for 5 additional Uno libraries:

You can try this today - see the NuGets listed above. Documentation of the new features plus a new getting started guide is coming with the next release - soon!

June 27, 2023

2.2 Release & start of .NET MAUI support

March 25, 2023

Poll results are in! And the winner is...

The March 2023 poll results on what to build next for C# Markup 2 are in!

A surprise addition was the ask for C# Markup 2 for Avalonia UI in the replies; it got a big response that catapulted it into a very close 2nd place.

Here are the results for the poll including the likes for "Other" options Blazor and AvaloniaUI:

And the winner is: C# Markup 2 for MAUI!
Watch and star this repo to catch the release; you can also watch #CSharpForMarkup tweets for progress. Thanks for your response!

Feb 28, 2023

Major Release - C# Markup 2 version 2.0 for WinUI 3!

C# Markup 2 version 2.0 for WinUI 3 is here! Completely updated to .NET 7, C# 11 and the latest Windows App SDK and Uno Platform. With many improvements including 6 supported target platforms, C# hot reload support and dotnet new project templates.

Brought to you by Applicita

Special thanks go to Applicita for making this release possible; it's inspiring to see a company support OSS in this way (Applicita also open-sourced several other useful libraries)

More on what's new in this release here.

Feb 16, 2023

A new release of C# Markup 2 for WinUI 3 and Uno Platform is coming in Feb 2023

Updated to .NET 7, C# 11 and the latest Windows App SDK and Uno Platform. With many improvements - including C# hot reload support and a dotnet new project template. Watch this space!

April 14, 2022

New 0.8 release: adds ControlTemplate support and Style improvements!

See here and here for the full list of improvements

February 15, 2022

New 0.6 release: adds WPF and many improvements!

See here for the full list of improvements

November 30, 2021

C# Markup 2 announced at UNOCONF 2021!

This first preview targets WinUI 3 and Uno Platform - including browser webassembly - with C# 10 and .NET 6. It supports .NET Hot Reload for a fast inner dev loop.

See the C# Markup 2 announcement at UNOCONF 2021:

  1. Clone this repo
  2. Open CSharpMarkup.Wpf.Examples.sln and explore the source for the example pages. Note how page markup and page logic are separated in partial class files, and integrated with Build(), Assign() and Invoke().
  3. .NET Hot Reload is supported; edit and save the page markup in VS 2022 while debugging to see instant updates
  4. To learn how to use C# Markup 2, read the features description below and experiment in the example app
  5. To build your own app, reference from a .NET 6 WPF project and create the C# Markup UI windows, pages etc in that project. Note that for existing apps you can reference (WPF / class library) projects that target older .NET versions from the .NET 6 project, so you can add C# Markup UI to your app without having to migrate existing logic and/or WPF UI to .NET 6 and C# 10.
Getting started for WinUI 3 and Windows App SDK / Uno Platform
  1. First check if your development environment is ready:

  2. Either choose an existing Uno Platform 5.2 solution, or create a new one with the Uno Platform Template Wizard or the dotnet new unoapp template. Feel free to select any options; C# Markup 2 fully supports Uno 5.2 with .NET 8 or .NET 7, MVUX or MVVM, XAML or Uno C# Markup, on all target platforms.

  3. Install the latest Modern.CSharp.Templates for dotnet new to get these templates for Windows App SDK, Uno Platform and more

    dotnet new install Modern.CSharp.Templates

    To see help about the template parameters:

    dotnet new mcs-uno-markup2 -h
  4. Add a C# Markup 2 project to the Uno Platform solution, e.g.:

    cd C:\Repos\UnoApp1
    dotnet new mcs-uno-markup2 --appRootNamespace InnoWvate.UnoApp1 --presentation mvux --renderer skia --allow-scripts Yes

    This will:

    Note that you can use the --name parameter of dotnet new to specify the name of your existing Uno project, if that differs from the solution folder name (in above example, UnoApp1). The specified name will be used with the .Presentation suffix for the new project as well.

  5. Open or reload the Uno solution and follow the steps in the Readme.md of the Presentation project to get started.

To learn how to use C# Markup 2, read the features description below.

Fore a more complete example, see the example app in this repo.

C# Markup 2 contains a full declarative, fluent API for existing UI frameworks. It surfaces virtually every layout, view and property, including attached properties, and includes full inline documentation that links each markup helper / parameter to the inline documentation for the underlying UI object / property.

The rich UI frameworks that C# Markup 2 surfaces can contain as much as 500+ UI object types. E.g. layouts, views and styles, but also brushes, rich text elements, drawing primitives, transformations, animations, visual states and more. In addition C# Markup offers powerful and concise convenience API's for layout, bindings, convertors, templates and more.

Layouts, views, properties and property values look like this:

All properties can be set with extension methods: properties defined on the view type or it's base types, as well as attached properties.

Properties that are defined directly on the view type can alternatively be set with named parameters:

This is mainly useful for properties that take primitive types.

Properties that take enum values have extension methods so the enum name does not have to be repeated
(as in TextAlignment: TextAlignment.Center):

Attached property names are prefixed with the defining type plus underscore:

You can set multiple attached property values for the same defining type in one call:

In addition to this, there are convenience overloads for some view types with just the most commonly used parameters:

Property value converters

Implicit converters are provided in the to subnamespace for common property value types:

These are:

An example using to.Point:

Button() .Background (RadialGradientBrush (Center: (50, 50), GradientOrigin: (100, 50)))

An example using to.TimeSpan and to.Duration:

ColorAnimation (BeginTime: "0:0:5", Duration: 2.5)

In many cases the inline documentation on the to. type describes the supported values and formatting; especially for strings this can avoid guesswork.

Styles can be assigned like this:

And defined like this:

In WPF you can bind a style setter value (WinUI 3 does not support this):

A DataTemplate is passed in as a Func<UIElement>:

A ControlTemplate can be created like this:

Here is how you can use a ControlTemplate in an implicit or explicit Style:

Enums for Grid rows and columns

You can use enums instead of numbers for Grid rows and colums. This improves readability and saves you from manually renumbering rows and columns when adding/removing/reordering them

Shorthand helpers are included as an alternative to common combinations of markup helpers:

Insert layout children: conditional and Spread

All layouts ignore null values in their children; this makes it possible to have conditional views depending on the value of an expression at page (re) build time.

The Spread helper allows to insert a variable number of children at a specific position in the children list (similar to what Flutter offers).

Thanks to the C# 10 CallerArgumentExpression attribute, you don't have to use strings or nameof() to specify binding paths with good performance. Instead you can use C# expressions and enjoy all the goodness that they bring: full intellisense, compiler checked, renaming support :

Note from the intellisense description in above image that the pathExpression parameter supports several convenience binding syntaxes, which allows to:

Any surrounding ", @ or whitespace characters in pathExpression are ignored

Bind supports almost all functionality that the UI framework offers for binding. In addition, there are many Bind overloads that allows to:

Page anatomy - separate markup and UI logic

A typical markup page starts like this:

FlutterPage.cs:

using CSharpMarkup.<UI framework name>;
using static CSharpMarkup.<UI framework name>.Helpers;

namespace Examples;

partial class FlutterPage
{
    public void Build() => Content = 

Note the use of partial class; this lets you separate the UI markup from UI logic:

FlutterPage.logic.cs:

using <UI framework namespace>.Controls;

namespace Examples;

public sealed partial class FlutterPage : Page, IBuild
{
    readonly FlutterViewModel vm;

    public FlutterPage()
    {
        InitializeComponent(); // Only needed for WinUI
        DataContext = vm = <obtain viewmodel instance>;
        Build();
Namespace separation of markup and UI logic

IMPORTANT:

Integrate UI markup with UI logic

With Assign and Invoke you can integrate UI markup with UI logic:

SearchPage.cs:

SearchPage.logic.cs:

SearchPage.cs:

SearchPage.logic.cs:

Note:
In SearchPage.cs, StackPanel and TextBox are markup object types, while
in SearchPage.logic.cs they are the corresponding UI framework object types

Development workflow tips Improve markup colorization in Visual Studio

There is no C# Markup IDE extension (yet...) to properly colorize markup, however C# Markup readability can be improved with this workaround in Visual Studio options:

Under Fonts and Colors, copy the color of User Types - Classes to User Members - Methods (with the Custom... button). Now the markup color for views and properties will no longer be the same.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4