Syntax & Grammar
Understanding the structure of a Nimbus application. Learn how XML maps to UI and Logic.
App Structure
Every Nimbus application starts with a root <App> element. This element defines the main window properties and contains three main sections:
<UI>
Defines the visual layout, controls, and appearance of your application.
<Logic>
Contains variables, event handlers, and application logic.
<Styles>
Optional section for defining reusable styles and themes.
<App Name="My App" Width="800" Height="600" Theme="Dark">
<!-- 1. User Interface -->
<UI>
<Grid>
<!-- Controls go here -->
</Grid>
</UI>
<!-- 2. Application Logic -->
<Logic>
<!-- Handlers go here -->
</Logic>
<!-- 3. Styles (Optional) -->
<Styles>
<!-- Custom styles go here -->
</Styles>
</App>
UI Definition
Nimbus uses a declarative XML syntax for UI that maps directly to WPF controls. You don't need to know XAML namespaces or complex bindings.
Attributes
Attributes define properties like size, color, and events. Most attributes support simple values or binding expressions.
<Button
Name="btnSubmit" <!-- Unique ID -->
Content="Submit" <!-- Text to display -->
Width="120" Height="40" <!-- Size -->
Background="#0078D4" <!-- Color (Hex) -->
onClick="HandleSubmit" <!-- Event Handler -->
/>
Hierarchy
Controls are nested to create layouts. Containers like Grid, StackPanel, and Border can hold other controls.
<Border Background="#333" CornerRadius="8" Padding="20">
<StackPanel>
<TextBlock Text="Title"/>
<TextBox Placeholder="Enter name..."/>
</StackPanel>
</Border>
Logic Definition
Logic is defined using declarative commands inside <Handler> blocks. Handlers are triggered by events (like onClick).
<Logic>
<!-- Variable Declaration -->
<Var Name="count" Value="0" Type="int"/>
<!-- Event Handler -->
<Handler Name="Increment">
<Increment Var="count"/>
<Set Target="lblDisplay" Property="Text" Value="{count}"/>
<If Condition="{count} > 10">
<Alert Message="Limit reached!"/>
<Set Var="count" Value="0"/>
</If>
</Handler>
</Logic>
Variables & Binding
Nimbus supports dynamic data binding using the {variable} syntax.
State Variables
Access variables defined in the <Logic> section.
<TextBlock Text="Current count: {count}"/>
Control Properties
Access properties of other UI controls using {ControlName.Property}.
<!-- Copy text from TextBox to Label -->
<Set Target="lblOutput" Property="Text" Value="{txtInput.Text}"/>
Expressions
You can use simple expressions in Condition attributes for logic flow.
| Operator | Description | Example |
|---|---|---|
== |
Equals | {status} == 'active' |
!= |
Not Equals | {count} != 0 |
> |
Greater Than | {age} > 18 |
AND / && |
Logical AND | {isValid} && {hasPaid} |
OR / || |
Logical OR | {isAdmin} || {isMod} |
<If Condition="{age} >= 18 AND {hasLicense} == 'true'">
<Enable Control="btnDrive"/>
<Else>
<Disable Control="btnDrive"/>
</If>