Table of Contents

Class Style<TTarget>

Namespace
Icy.UI.Styles
Assembly
IcyUI.dll

A strongly-typed, fluent builder over Style for defining styles in C# code with compile-time-checked, IntelliSense-friendly property references instead of string-keyed setters.

public class Style<TTarget> : Style, IImplicitResourceKey where TTarget : UIElement

Type Parameters

TTarget

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

Inheritance
Style<TTarget>
Implements
Inherited Members
Extension Methods

Remarks

Set<TValue>(Expression<Func<TTarget, TValue>>, TValue) resolves the target property's name and writes it into the same underlying Setters dictionary the string-keyed API and markup use, so both authoring styles stay interchangeable and go through the exact same Apply(UIElement) logic.

Constructors

Style()

Initializes a new instance of the Style<TTarget> class.

public Style()

Methods

InheritsFrom(Style)

Sets the style this style inherits setters and state groups from, and returns this style for further chaining.

public Style<TTarget> InheritsFrom(Style baseStyle)

Parameters

baseStyle Style

The style to inherit from.

Returns

Style<TTarget>

This style, for fluent chaining.

Set<TValue>(Expression<Func<TTarget, TValue>>, TValue)

Sets the value a property this style targets should have, and returns this style for further chaining.

public Style<TTarget> Set<TValue>(Expression<Func<TTarget, TValue>> property, TValue value)

Parameters

property Expression<Func<TTarget, TValue>>

A simple property-access expression identifying the property to set, e.g. x => x.Background.

value TValue

The value to set.

Returns

Style<TTarget>

This style, for fluent chaining.

Type Parameters

TValue

The type of the property's value.

WithStateGroup(VisualStateGroup)

Adds a visual-state group this style registers on every element it's applied to, and returns this style for further chaining.

public Style<TTarget> WithStateGroup(VisualStateGroup group)

Parameters

group VisualStateGroup

The group to add.

Returns

Style<TTarget>

This style, for fluent chaining.