Skip to content

Layout, scroll, two NSS dialects ​

Separate layout constraints, scroll ownership and style dialects before tuning a page. A retained layout must remain valid when content and viewport sizes change.

Version scope: these source-level examples target v2.0.0.alpha.14. Use the Plugin SDK for current Wasm plugin authoring.

Make clear, scalable layout with consistent input geometry. NXML owns structure; choose the correct presentation dialect.

Containers and sizing ​

Page/ContentHost wrap Element; StackPanel uses Orientation/Spacing; Shell is finite defaults. Pagers are supported primitives, not arbitrary DOM/Flex.

xml
<Page Key="LayoutExample">
  <StackPanel Orientation="Horizontal" Spacing="16" Padding="24">
    <StackPanel Key="Left" Weight="1" MinWidth="200" MaxWidth="320">
      <Text Content="Account" />
    </StackPanel>
    <StackPanel Key="Right" Weight="2" MinWidth="280">
      <Text Content="Version" />
    </StackPanel>
  </StackPanel>
</Page>

Weight participates in allocation while Min/Max still constrain it. Alignments are Stretch/Start/Center/End. NXML thickness is one number or four comma values left/top/right/bottom, not CSS whitespace pairs.

Host base NSS ​

css
#TitleMain { FontSize: 26; Foreground: #23466c; }
.status-card { CornerRadius: 16; Background: #edf3fa; }
Text { FontSize: 15; }
Button { Height: 38; Padding: 12,6,12,6; }

NssStyleSheet supports simple type/class/key/* and selector lists, not compound Text#TitleMain, pseudo-classes, tokens, or conditions. It forms base values from component defaults → sheet → explicit markup.

csharp
var styles = NssStyleSheet.Parse(baseStyleText);
var ir = NxmlCompiler.Compile(NxmlParser.Parse(pageText), components, styles);

Theme NSS/1 ​

AspectHost base NSSNTP NSS/1
CompilerNssStyleSheet.ParseNssThemeCompiler.Compile
InputHost templatesOrdered styles/options/environment/resources
SelectorsSimple type/class/key/*Compound/relations/finite attributes/state
Tokens/conditions/motionNoFinite support
ThicknessOne/four comma valuesOne/two/four, documented whitespace/comma order
ApplicationBase IRIndependent style-only generation

Same suffix is not identical grammar. Theme activation preserves identity and does not reconstruct pages merely to recolor them.

Scroll and indicators ​

xml
<StackPanel Key="LogView" Scroll="true" ShowsVerticalIndicator="true"
            StickToEnd="true" ScrollGesture="true" Height="220">
  <Text Content="First log entry" />
  <Text Content="Second log entry" />
</StackPanel>

Host owns retained scrolling, not manually moved child Top values. Facts require Scroll and supported stack/Dynamic layouts. Expanding command capsules have a separate horizontal-only contract requiring authored HoverExpand/Scroll; only horizontal indicator and vertical-wheel routing are admitted there.

Text/images/loading ​

Content supplies text; WrapText/MaxLines/TrimOverflow are finite. Image requires Source resolved by Host, not arbitrary IO authority.

xml
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Spacing="12">
  <ProgressRing Label="Loading resources" Width="40" Height="40" />
  <Text Content="Loading resources…" />
</StackPanel>

ProgressRing wraps Progress with Ring/Indeterminate. Host selects empty loading versus retained append behavior.

Virtual content ​

Host owns logical items, realized windows, spacers, and anchors. Dynamic is a container, not automatic infinite-list virtualization. Use stable retained fragments/Reload/Reorder instead of Clear/rebuild, with shared Host metrics when virtualized.

Continue with state and intent.

Implementation references ​

Check your result ​

Resize with long text and an overflowing list; verify the intended container owns scrolling.

Site documentation: CC BY-SA 4.0. Imported SDK documents: Apache-2.0 as marked.