Avalonia solo in codiceEnglish

API › RAVAL

RAva class

Il riferimento e' in inglese: viene dai commenti del sorgente di RAVAL, che dalla 2.0 ha nomi e commenti in inglese.

public static class RAva

Fluent extensions to build Avalonia user interfaces in code only: each one returns the control itself.

Metodi

static T Margin<T>(T c, double all)

The same margin on all four sides.

static T Margin<T>(T c, double horiz, double vert)

Horizontal and vertical margin.

static T Margin<T>(T c, double l, double t, double r, double b)

Left, top, right, bottom margin.

static T Align<T>(T c, HorizontalAlignment h, VerticalAlignment v)

Horizontal and vertical alignment.

static T HAlign<T>(T c, HorizontalAlignment h)

Horizontal alignment.

static T VAlign<T>(T c, VerticalAlignment v)

Vertical alignment.

static T Width<T>(T c, double w)

Fixed width.

static T Height<T>(T c, double h)

Fixed height.

static T Column<T>(T c, int column, int span = 1)

The grid column (and how many it spans).

static T Row<T>(T c, int row, int span = 1)

The grid row (and how many it spans).

static T Dock<T>(T c, Dock side)

The side of the DockPanel.

static T Children<T>(T p, params Control[] children)

Adds the children to the panel.

static T Text<T>(T t, string text)

The text of a TextBlock.

static T Content<T>(T c, object content)

The content of a ContentControl. A text with the access underscore («_Save») also gives the accessible name without the underscore: see NameFromContent in RAvaAccess.cs.

static T Child<T>(T d, Control child)

The child of a Border (or of another Decorator).

static T ToolTip<T>(T c, string text)

The tip shown when the mouse rests on the control.

static T OnClick<T>(T b, Action action)

The method to call when the button is clicked.

static T Resource<T>(T c, AvaloniaProperty property, string key)

The property bound to a theme resource (it changes by itself with the theme).

static IBrush ThemeBrush(Control c, string key, IBrush fallback)

The brush of a resource in the control's current theme, for those who draw by themselves in Render; fallback if the key is missing or is not a brush.

static T AutomationName<T>(T c, string name)

The accessible name: what the screen reader (Narrator, VoiceOver, Orca) announces for the control. Needed above all by the buttons with an icon only, which would be announced by their symbol («✕»).

static SolidColorBrush Brush(string color)

A solid color brush from a color written as in HTML: «#1a7fb5», «#801a7fb5» (the first two digits are the opacity), «#18b» or a name like «Red». A badly written color throws an exception.

static SolidColorBrush Brush(uint argb)

A solid color brush from a 0xAARRGGBB number (AA = opacity, FF = opaque).

static T OnTextChanged<T>(T t, Action<string> action)

The method to call with the new text, at every change of the TextBox.

static T OnEnter<T>(T t, Action action)

The method to call when Enter is pressed in the TextBox. It listens in the Tunnel phase, before the box: so it also works with AcceptsReturn, where the TextBox would use Enter to start a new line and mark it handled. Then Enter is marked handled: the box does not start a new line, and the Tunnel handlers of the same control added before OnEnter (called after: the last added goes first) do not see it.

static T OnChecked<T>(T c, Action<bool> action)

The method to call with the new state (true = checked) of a CheckBox, ToggleSwitch, RadioButton...

static T OnSelectionChanged<T>(T l, Action<object> action)

The method to call with the chosen item (null if none) of a ListBox, ComboBox...

static DispatcherTimer Every(TimeSpan interval, Action action)

A timer, already started, that calls the method every interval, on the user interface thread. Stop it with Stop() when it is no longer needed (for instance when the window closes).

static T OnThemeChanged<T>(T c, Action action)

The method to call when the control goes from the light theme to the dark one or back: for those who draw in Render, which Avalonia does not redraw by itself when the theme changes.

static TextBlock Caption(string text, string key = "InkSoft")

The title of a section: upper case, small, in the resource key (a muted ink).

static Border Card(Control content, string backgroundKey = "Panel", string borderKey = "Border")

A rounded panel with a 1 pixel border around the content; background and border come from the theme resources.

static Border Bar(Control content, bool top, string backgroundKey = "Bar", string borderKey = "Border")

A bar across the window (toolbar at the top, status bar at the bottom), with the dividing line on the side of the content.

static Button ToolbarButton(string text, string tip, Action action)

A flat button of a toolbar, with its tooltip.

static TextBox CodeBox(int lines)

A multiline text box in a monospaced font, without wrapping, tall enough for the given lines.

static MenuItem OnClick(MenuItem m, Action action)

The method without arguments to call when the item is chosen, like OnClick of the Button. It is not generic: a second generic OnClick with a different constraint would have the same signature (error CS0111); so a Button still uses the generic one, a MenuItem this.

static MenuItem HotKey(MenuItem m, string gesture)

The keyboard shortcut of the item («Ctrl+S», «Ctrl+Shift+N», «F5»): written on the right of the item and working. InputGesture only writes it; HotKey makes it work, even with the menu closed and the focus in a TextBox (tested in Avalonia 12.1.4). Do not use it for Ctrl+C, Ctrl+X, Ctrl+V and Ctrl+A: the TextBox handles them itself. Put the item in the menu with Items.Add: with ItemsSource, while the menu is closed, it is not in the tree yet and the key does not work.

static StackPanel HStack(double spacing, params Control[] children)

A horizontal StackPanel with the given children, spacing pixels apart.

static StackPanel VStack(double spacing, params Control[] children)

A vertical StackPanel with the given children, spacing pixels apart.

static Grid Grid(string columns, string rows = "")

A Grid with columns and rows written as in Avalonia: «Auto» fits the content, «*» takes the space left, «2*» twice as much, a number is a fixed size. No rows = a single row.

static T Spacing<T>(T p, double spacing)

The space between the children of a StackPanel.

static T Spacing<T>(T g, double columns, double rows)

The space between the columns and the rows of a Grid.

static T FontSize<T>(T c, double size)

The font size, in pixels. On a panel it applies to all the text it contains.

static T FontWeight<T>(T c, FontWeight weight)

The font weight (normal, bold...).

static T Bold<T>(T c)

Bold text.

static T Italic<T>(T c)

Italic text.

static T FontFamily<T>(T c, string family)

The font family, by name («Consolas», «Segoe UI»...).

static T Foreground<T>(T c, IBrush brush)

The color of the text.

static T Foreground<T>(T c, string color)

The color of the text, written as in HTML («#1a7fb5», «#801a7fb5» with the opacity, «Red»).

static T Wrap<T>(T t)

The text wraps to a new line when there is no more room, instead of going out of the control.

static T TextAlign<T>(T t, TextAlignment alignment)

The alignment of the lines of text inside the TextBlock (left, center, right).

static T Border<T>(T c, double thickness, double radius = 0)

The border thickness and, if given, the radius.

static T CornerRadius<T>(T c, double radius)

The radius of the rounded corners.

static T BorderBrush<T>(T c, IBrush brush)

The color of the border.

static T BorderBrush<T>(T c, string color)

The color of the border, written as in HTML.

static T Padding<T>(T c, double all)

The space inside the border, the same on all 4 sides.

static T Padding<T>(T c, double horiz, double vert)

The space inside the border: horizontal, vertical.

static T Padding<T>(T c, double l, double t, double r, double b)

The space inside: left, top, right, bottom.

static T Background<T>(T c, IBrush brush)

The background: panels, Border, TextBlock and templated controls (windows included).

static T Background<T>(T c, string color)

The background, written as in HTML.

static T Visible<T>(T c, bool visible)

Visible or hidden (hidden takes no space).

static T Enabled<T>(T c, bool enabled)

Enabled or not: a disabled control looks dimmed and does not respond.

static T Opacity<T>(T c, double opacity)

The opacity, from 0 (invisible) to 1 (opaque).

static T Classes<T>(T c, params string[] classes)

Adds the style classes («accent» for the main button of the Fluent theme...).