Table of Contents

Class Style

Namespace
Icy.UI.Styles
Assembly
IcyUI.dll

Represents a set of property values (and, optionally, VisualStateGroups) applied to every UIElement whose Style is set to this instance.

[MarkupSetterCollection("Setters")]
public class Style : IImplicitResourceKey
Inheritance
Style
Implements
Derived
Inherited Members
Extension Methods

Constructors

Style(Type)

Represents a set of property values (and, optionally, VisualStateGroups) applied to every UIElement whose Style is set to this instance.

public Style(Type targetType)

Parameters

targetType Type

The type of element this style is meant to be applied to.

Properties

BasedOn

Gets or sets a style this style inherits setters and state groups from.

public Style? BasedOn { get; set; }

Property Value

Style

Remarks

Applied first, so this style's own setters/state groups take precedence when both set the same property.

ReplacesTheme

Gets or sets a value indicating whether this style replaces the theme's style for its type instead of being applied on top of it. false by default.

public bool ReplacesTheme { get; set; }

Property Value

bool

Remarks

A style that isn't the theme's own (a keyed style, or an implicit style in an element's Resources) is applied over the theme's style for its type: the theme supplies the template, colors and visual states, and this style changes only what it sets. Set this to true for a control that should look like nothing but this style, for example a text box drawn without the theme's border inside another control.

Setters

Gets the property values this style sets, keyed by property name.

public Dictionary<string, object?> Setters { get; }

Property Value

Dictionary<string, object>

Remarks

Resolved against PropertyRegistry when applied (see Apply(UIElement)), so only properties registered via RegisterReferenceAttribute (or an attached property) can be targeted by name here.

StateGroups

Gets the visual-state groups this style registers on every element it's applied to.

public List<VisualStateGroup> StateGroups { get; }

Property Value

List<VisualStateGroup>

TargetType

Gets the type of element this style is meant to be applied to.

public Type TargetType { get; }

Property Value

Type

Methods

Apply(UIElement)

Applies this style's setters and state groups to control.

public void Apply(UIElement control)

Parameters

control UIElement

The element to apply this style to.

Exceptions

InvalidOperationException

This style's BasedOn chain contains a cycle.