Browse Source
* Add InheritDataTypeFromAttribute and use it in TemplateBinding * Add failing tests for TemplateBinding depending on a scope * Update XamlX and RoslynTypeSystem * Add missing interface implementations * Improve errors readability in XamlAvaloniaPropertyHelper * Use more specific TryGetCorrectlyTypedValue overloads * Finally, respect InheritDataTypeFromAttribute in the AvaloniaProperty parser * Add some docs * Output better exception * Update XamlX * Add missing docs * Add attribute to well known types * Add Correctly_Resolve_TemplateBinding_In_Theme_Detached_Template test and fix ColorPicker usage --------- Co-authored-by: Steven Kirk <grokys@users.noreply.github.com>pull/16143/head
committed by
GitHub
13 changed files with 249 additions and 24 deletions
@ -0,0 +1,44 @@ |
|||
using System; |
|||
|
|||
namespace Avalonia.Metadata; |
|||
|
|||
/// <summary>
|
|||
/// Represents the kind of scope from which a data type can be inherited. Used in resolving target for AvaloniaProperty.
|
|||
/// </summary>
|
|||
public enum InheritDataTypeFromScopeKind |
|||
{ |
|||
/// <summary>
|
|||
/// Indicates that the data type should be inherited from a style.
|
|||
/// </summary>
|
|||
Style = 1, |
|||
|
|||
/// <summary>
|
|||
/// Indicates that the data type should be inherited from a control template.
|
|||
/// </summary>
|
|||
ControlTemplate, |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Attribute that instructs the compiler to resolve the data type using specific scope hints, such as Style or ControlTemplate.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// This attribute is used to configure markup extensions like TemplateBinding to properly parse AvaloniaProperty values,
|
|||
/// targeting a specific scope data type.
|
|||
/// </remarks>
|
|||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)] |
|||
public sealed class InheritDataTypeFromAttribute : Attribute |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="InheritDataTypeFromAttribute"/> class with the specified scope kind.
|
|||
/// </summary>
|
|||
/// <param name="scopeKind">The kind of scope from which to inherit the data type.</param>
|
|||
public InheritDataTypeFromAttribute(InheritDataTypeFromScopeKind scopeKind) |
|||
{ |
|||
ScopeKind = scopeKind; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets the kind of scope from which the data type should be inherited.
|
|||
/// </summary>
|
|||
public InheritDataTypeFromScopeKind ScopeKind { get; } |
|||
} |
|||
Loading…
Reference in new issue