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
Methods
Find(string)
Finds the element registered under name.
public UIElement? Find(string name)
Parameters
namestringThe name to look up.
Returns
GetScope(UIElement)
Gets the name scope attached to root, if it has one.
public static MarkupNameScope? GetScope(UIElement root)
Parameters
rootUIElementThe 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
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
rootUIElementThe root element of the tree the scope covers.
scopeMarkupNameScopeThe scope to attach.
TryFind(string, out UIElement?)
Attempts to find the element registered under name.
public bool TryFind(string name, out UIElement? element)
Parameters
Returns
Unregister(string)
Removes name from this scope, so it can be registered again for another element.
public bool Unregister(string name)
Parameters
namestringThe name to remove.
Returns
Exceptions
- ArgumentException
nameis null or empty.