VincentH-Net / CSharpForMarkup

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

Add a Label Content property #30

Closed scottcg closed 2 years ago

scottcg commented 2 years ago

Add a Label Content property helper to allow attaching text/string to a Label; Label as only a constructor at the monent

Label("label goes here")

To allow for this (currently this is an error):

Label()
    .Content("label goes here")
VincentH-Net commented 2 years ago

What scenario would this enable? Both are functionally equivalent.

A core rule of C# markup API is that child controls are specified as parameters, not in extension methods. This allows for consistency (one place to specify children) and performance optimization (C# markup is almost allocation free because controls are only created in parameters, not in the middle of a fluent extension method chain).

If it helps, content support has been improved since this issue was reported; e.g. in WPF use Label(UIObject Content) to specify content of any type that accepts - string, DateTime, UIElement, Panel

scottcg commented 2 years ago

I don't recall my thinking, if it was having a "separate thing" once I'd gotten around to working out FrameworkElementFactory - but as you say there's no real difference.

VincentH-Net commented 2 years ago

Thanks for clarifying; I will close this as not an issue.