Table of Contents

Class ResourceHostExtensions

Namespace
CarinaStudio.Controls
Assembly
CarinaStudio.AppBase.Avalonia.dll

Extensions for Avalonia.Controls.IResourceHost.

public static class ResourceHostExtensions
Inheritance
ResourceHostExtensions
Inherited Members

Methods

BindToResource<T>(T, AvaloniaProperty, object)

Bind property to given resource.

public static IDisposable BindToResource<T>(this T target, AvaloniaProperty property, object resourceKey) where T : AvaloniaObject, IResourceHost

Parameters

target T

Target object.

property AvaloniaProperty

Property to bind.

resourceKey object

Resource key.

Returns

IDisposable

Token of binding.

Type Parameters

T

Type of target object.

FindResourceOrDefault<T>(IResourceHost, object, ThemeVariant?, T)

Find resource with given type or use default value.

public static T FindResourceOrDefault<T>(this IResourceHost resourceHost, object key, ThemeVariant? theme, T defaultValue = default)

Parameters

resourceHost IResourceHost

Avalonia.Controls.IResourceHost.

key object

Resource key.

theme ThemeVariant

Theme.

defaultValue T

Default value.

Returns

T

Resource with given key and type, or default value.

Type Parameters

T

Type of resource.

Remarks

This is a thread-safe method.

FindResourceOrDefault<T>(IResourceHost, object, T)

Find resource with given type or use default value.

public static T FindResourceOrDefault<T>(this IResourceHost resourceHost, object key, T defaultValue = default)

Parameters

resourceHost IResourceHost

Avalonia.Controls.IResourceHost.

key object

Resource key.

defaultValue T

Default value.

Returns

T

Resource with given key and type, or default value.

Type Parameters

T

Type of resource.

Remarks

This is a thread-safe method.

TryFindResource<T>(IResourceHost, object, ThemeVariant?, out T?)

Try finding resource with given type.

public static bool TryFindResource<T>(this IResourceHost resourceHost, object key, ThemeVariant? theme, out T? res) where T : struct

Parameters

resourceHost IResourceHost

Avalonia.Controls.IResourceHost.

key object

Resource key.

theme ThemeVariant

Theme.

res T?

Found resource.

Returns

bool

True if resource found.

Type Parameters

T

Type of resource.

Remarks

This is a thread-safe method.

TryFindResource<T>(IResourceHost, object, ThemeVariant?, out T?)

Try finding resource with given type.

public static bool TryFindResource<T>(this IResourceHost resourceHost, object key, ThemeVariant? theme, out T? res) where T : class

Parameters

resourceHost IResourceHost

Avalonia.Controls.IResourceHost.

key object

Resource key.

theme ThemeVariant

Theme.

res T

Found resource.

Returns

bool

True if resource found.

Type Parameters

T

Type of resource.

Remarks

This is a thread-safe method.

TryFindResource<T>(IResourceHost, object, out T?)

Try finding resource with given type.

public static bool TryFindResource<T>(this IResourceHost resourceHost, object key, out T? res) where T : struct

Parameters

resourceHost IResourceHost

Avalonia.Controls.IResourceHost.

key object

Resource key.

res T?

Found resource.

Returns

bool

True if resource found.

Type Parameters

T

Type of resource.

Remarks

This is a thread-safe method.

TryFindResource<T>(IResourceHost, object, out T?)

Try finding resource with given type.

public static bool TryFindResource<T>(this IResourceHost resourceHost, object key, out T? res) where T : class

Parameters

resourceHost IResourceHost

Avalonia.Controls.IResourceHost.

key object

Resource key.

res T

Found resource.

Returns

bool

True if resource found.

Type Parameters

T

Type of resource.

Remarks

This is a thread-safe method.