VincentH-Net / CSharpForMarkup

Concise, declarative C# UI markup for .NET browser / native UI frameworks
MIT License
748 stars 43 forks source link

Create TextBlock inlines helper #26

Closed scottcg closed 2 years ago

scottcg commented 2 years ago

TextBlock can contain children (inlines), the current helper only allows a single Inline (which is the only option support by the WPF constructor).

The following is an example that isn't currently supported:

<TextBlock><Run Foreground="#FFCFD3DA" Text="Text1" /><Run FontWeight="Normal" Text="Text2" /></TextBlock>

Maybe something like:

public static TextBlock TextBlock(System.Windows.Documents.Inline[] chidren)
{
    var ui = new Windows.Controls.TextBlock();
    foreach (var ch in chidren)
    {
        ui.Inlines.Add(ch);
    }

    return ui;
}
VincentH-Net commented 2 years ago

Inline support has been improved since this issue was reported; currently the equivalent of above XAML in C# Markup is:

TextBlock( Run("Text1").Foreground("#FFCFD3DA"), Run("Text2").FontWeight("Normal") )