AXSG supports C#-based expressions directly in XAML attribute values while keeping the XAML document valid XML and preserving the local XAML binding context.
This feature exists for scenarios where plain property bindings are too limited and the user needs lightweight logic such as interpolation, arithmetic, boolean conditions, ternaries, or method calls without introducing converters, multibinding scaffolding, or extra code-behind glue.
Use the explicit expression marker when the value should always be interpreted as C#:
<TextBlock Text="{= FirstName + ' ' + LastName}" />
<TextBlock Text="{= (Price * Quantity).ToString('0.00')}" />
<Button IsEnabled="{= HasAccount && AgreedToTerms}" />
Simple attribute values can also be interpreted as expressions when the target site is an expression-capable value position:
<TextBlock Text="{ProductName}" />
<TextBlock Text="{IsVip ? 'Gold' : 'Standard'}" />
<Button IsEnabled="{HasAccount && AgreedToTerms}" />
Interpolated expressions are supported directly:
<TextBlock Text="{$'{Quantity}x {ProductName}'}" />
<TextBlock Text="{$'Total: ${Price * Quantity:F2}'}" />
Expression binding resolution uses the current XAML semantic context.
Resolution order is:
x:DataType, inferred compiled-binding source, or
surrounding typed source)This lets the same expression syntax work across:
The current implementation supports normal C# expression semantics for:
Examples:
<TextBlock Text="{= Count * Count}" />
<TextBlock Text="{= Nickname ?? ('alias:' + FirstName)}" />
<TextBlock Text="{= Tags[0] + ', ' + Tags[1]}" />
<TextBlock Text="{= FormatSummary(FirstName, LastName, Count)}" />
<TextBlock IsVisible="{!IsLoading}" />
Event values can use inline lambda expressions when the target event has a delegate type that can be matched by the provided lambda shape.
<Button Content="{$'Clicked {ClickCount} times'}"
Click="{(s, e) => ClickCount++}" />
Statement-style event logic that exceeds a single expression should use the inline C# surface documented in Inline C# Code.
Common failures surface as AXSG semantic diagnostics, for example:
Expressions participate in the AXSG language service.
Supported editor features include:
This applies to:
Expressions are compiled into generated binding/runtime helpers rather than interpreted through reflection.
Hot reload support remains available, but changes that alter generated code shape may be handled through the generated reload path instead of a pure runtime fallback path.
Use expression syntax when the code is naturally a value expression or a compact event lambda.
Use inline C# blocks when you need:
See Inline C# Code for that surface.