Table of Contents

Class MarkupExtensionContext

Namespace
Icy.Markup
Assembly
IcyUI.dll

What a IMarkupExtension is given to resolve its value: the object and property it is being resolved for, and what the loader knows about the surrounding document.

public sealed class MarkupExtensionContext
Inheritance
MarkupExtensionContext
Inherited Members
Extension Methods

Constructors

MarkupExtensionContext(object, MarkupMember, IcyConfiguration, MarkupNameScope, IReadOnlyList<UIElement>, IXmlLineInfo?, string?, UIElement?, Type?)

What a IMarkupExtension is given to resolve its value: the object and property it is being resolved for, and what the loader knows about the surrounding document.

public MarkupExtensionContext(object target, MarkupMember member, IcyConfiguration configuration, MarkupNameScope names, IReadOnlyList<UIElement> elementStack, IXmlLineInfo? node, string? sourcePath, UIElement? templatedControl = null, Type? dataType = null)

Parameters

target object

The object whose property the extension is resolving a value for.

member MarkupMember

The property the extension is resolving a value for.

configuration IcyConfiguration

The configuration the loader is resolving the document through.

names MarkupNameScope

The document's x:Name scope.

elementStack IReadOnlyList<UIElement>

The elements currently under construction, innermost last.

node IXmlLineInfo

The extension's position in the source document, for error reporting.

sourcePath string

The document's path, for error reporting.

templatedControl UIElement

The control a ControlTemplate's content is being built for, when this context belongs to template content - null for an ordinary document.

dataType Type

The x:DataType in effect where the extension is used, or null when none is declared.

Properties

Configuration

Gets the configuration the loader is resolving the document through.

public IcyConfiguration Configuration { get; }

Property Value

IcyConfiguration

DataType

Gets the type the data context is declared to have where the extension is used: the x:DataType of the nearest element, the target's own included, or null when none is declared.

public Type? DataType { get; }

Property Value

Type

Remarks

A template (DataTemplate, ControlTemplate) is a boundary: its content sees an x:DataType declared on the template element or inside it, never one from outside, since its items have a data context of their own.

ElementStack

Gets the UIElements currently under construction, innermost last - see MarkupLoader's private MarkupLoadContext.ElementStack for why this can't simply be Parent.

public IReadOnlyList<UIElement> ElementStack { get; }

Property Value

IReadOnlyList<UIElement>

Member

Gets the property the extension is resolving a value for.

public MarkupMember Member { get; }

Property Value

MarkupMember

Names

Gets the document's x:Name scope, for extensions that resolve an element by name.

public MarkupNameScope Names { get; }

Property Value

MarkupNameScope

Node

Gets the extension's position in the source document, for error reporting.

public IXmlLineInfo? Node { get; }

Property Value

IXmlLineInfo

SourcePath

Gets the document's path, for error reporting.

public string? SourcePath { get; }

Property Value

string

Target

Gets the object whose property the extension is resolving a value for.

public object Target { get; }

Property Value

object

TemplatedControl

Gets the control a ControlTemplate's content is being built for, or null when this context belongs to an ordinary (non-template) document.

public UIElement? TemplatedControl { get; }

Property Value

UIElement

Remarks

This is what {TemplateBinding} (see TemplateBindingExtension) reads as its binding source - it has no other way to reach "the control this template decorates," since that control is never itself part of ElementStack (it isn't being constructed by the same document load).