Avalonia Css
Source CodeδΈ­ζ–‡
  • Documentation
    • πŸŽ†Welcome
    • πŸŒοΈβ€β™‚οΈGet started
      • About Acss
      • Processes and concepts
      • Security
      • Performance Evaluation
      • Configuring the development environment
      • Debugging
      • About source code
      • FAQ
    • ❓How-to
      • Using Acss
        • Type Resolution
        • Configuration
        • Code Source
        • Extending Resources
      • Using Acss.Controls
      • Using Acss.Fluent
      • Using MessageBox
      • Using Senior
      • Using Acss.Behaviors
    • πŸ“Acss Syntax
      • Comment
      • Resource
      • Style
      • Animation
      • Behavior
    • πŸ’ŽBest Practices
      • Define a good control template
Powered by GitBook
On this page
  • Built-in resource types
  • Custom Resource Types

Was this helpful?

Edit on GitHub
  1. Documentation
  2. How-to
  3. Using Acss

Extending Resources

Acss's resources (AcssResource) support extensions. Currently we have some common resource types built-in, and you can also define your own resource types.

Built-in resource types

  1. Brush

  2. Color

  3. Double

  4. Int

  5. LinearBrush

  6. Thickness

  7. Transition

  8. BoxShadows

More built-in resource types will be added later in the programme.

Custom Resource Types

Acss's resources all inherit from the abstract class AcssResourceBaseAndFac, defined as follows:

public abstract class AcssResourceBaseAndFac<T> : AcssResource, IResourceFactory 
    where T : AcssResource, new()

You can inherit this class to extend your own resource types, for example in the following code we extend the resource type that defines Thickness.

The aliases for this type are "Thickness", "Thick", "StrokeThickness", " Margin", "Padding". Any of these aliases will be resolved to a Thickness resource in Acss code.

Note that aliases are not case insensitive. thick and thick refer to the same resource type, Thickness.

[ResourceType(nameof(Thickness))]
[ResourceType("Thick")]
[ResourceType("StrokeThickness")]
[ResourceType("Margin")]
[ResourceType("Padding")]
internal class ThicknessResource : AcssResourceBaseAndFac<ThicknessResource>
{
    protected override object? BuildValue(IAcssContext context, string valueString)
    {
        return valueString.TryParseThickness();
    }
}
PreviousCode SourceNextUsing Acss.Controls

Last updated 1 year ago

Was this helpful?

❓