Table of Contents

Class MarkupNameScope

Namespace
Icy.Markup
Assembly
IcyUI.dll

The set of x:Named elements produced by one markup document, keyed by name.

public sealed class MarkupNameScope
Inheritance
MarkupNameScope
Inherited Members
Extension Methods

Remarks

One scope covers one document, so names only have to be unique within the file that declares them - two pages may each have an ok button. The scope is attached to the tree's root and reached from any element in it via FindControl<T>(UIElement, string).

A scope is a lookup table, not an ownership relation: it holds ordinary references to elements that the tree owns, and lives exactly as long as the root does.

Properties

Names

Gets the named elements in this scope.

public IReadOnlyDictionary<string, UIElement> Names { get; }

Property Value

IReadOnlyDictionary<string, UIElement>

Methods

Find(string)

Finds the element registered under name.

public UIElement? Find(string name)

Parameters

name string

The name to look up.

Returns

UIElement

The element, or null when nothing is registered under that name.

GetScope(UIElement)

Gets the name scope attached to root, if it has one.

public static MarkupNameScope? GetScope(UIElement root)

Parameters

root UIElement

The element to read the scope from.

Returns

MarkupNameScope

The attached scope, or null when the element isn't a markup root.

Register(string, UIElement)

Registers element under name.

public void Register(string name, UIElement element)

Parameters

name string

The name declared by x:Name.

element UIElement

The element to register.

Exceptions

MarkupException

A different element is already registered under this name.

SetScope(UIElement, MarkupNameScope)

Attaches scope to root.

public static void SetScope(UIElement root, MarkupNameScope scope)

Parameters

root UIElement

The root element of the tree the scope covers.

scope MarkupNameScope

The scope to attach.

TryFind(string, out UIElement?)

Attempts to find the element registered under name.

public bool TryFind(string name, out UIElement? element)

Parameters

name string

The name to look up.

element UIElement

The element, when this returns true.

Returns

bool

true when an element is registered under that name.

Unregister(string)

Removes name from this scope, so it can be registered again for another element.

public bool Unregister(string name)

Parameters

name string

The name to remove.

Returns

bool

true when the name was registered.

Exceptions

ArgumentException

name is null or empty.