Browse Source
Allow any object implementing INamed to be registered in a Xaml namescope (#14757)
Added INamed as direct interface of StyledElement, ahead of the removal of IStyleable
pull/14761/head
Tom Edwards
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with
5 additions and
3 deletions
-
src/Avalonia.Base/INamed.cs
-
src/Avalonia.Base/StyledElement.cs
-
src/Avalonia.Controls/Control.cs
-
src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AddNameScopeRegistration.cs
|
|
|
@ -1,7 +1,8 @@ |
|
|
|
namespace Avalonia |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// Interface for named elements.
|
|
|
|
/// Objects implementing this interface and providing a value for <see cref="Name"/> will be registered in the
|
|
|
|
/// relevant namescope when constructed in XAML.
|
|
|
|
/// </summary>
|
|
|
|
public interface INamed |
|
|
|
{ |
|
|
|
|
|
|
|
@ -33,6 +33,7 @@ namespace Avalonia |
|
|
|
ISetLogicalParent, |
|
|
|
ISetInheritanceParent, |
|
|
|
ISupportInitialize, |
|
|
|
INamed, |
|
|
|
#pragma warning disable CS0618 // Type or member is obsolete
|
|
|
|
IStyleable |
|
|
|
#pragma warning restore CS0618 // Type or member is obsolete
|
|
|
|
|
|
|
|
@ -24,7 +24,7 @@ namespace Avalonia.Controls |
|
|
|
/// - A <see cref="Tag"/> property to allow user-defined data to be attached to the control.
|
|
|
|
/// - <see cref="ContextRequestedEvent"/> and other context menu related members.
|
|
|
|
/// </remarks>
|
|
|
|
public class Control : InputElement, IDataTemplateHost, INamed, IVisualBrushInitialize, ISetterValue |
|
|
|
public class Control : InputElement, IDataTemplateHost, IVisualBrushInitialize, ISetterValue |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// Defines the <see cref="FocusAdorner"/> property.
|
|
|
|
|
|
|
|
@ -16,7 +16,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.Transformers |
|
|
|
if (node is XamlPropertyAssignmentNode pa) |
|
|
|
{ |
|
|
|
if (pa.Property.Name == "Name" |
|
|
|
&& pa.Property.DeclaringType.FullName == "Avalonia.StyledElement") |
|
|
|
&& pa.Property.DeclaringType.Interfaces.Any(t => t.FullName == "Avalonia.INamed")) |
|
|
|
{ |
|
|
|
if (context.ParentNodes().FirstOrDefault() is XamlManipulationGroupNode mg |
|
|
|
&& mg.Children.OfType<AvaloniaNameScopeRegistrationXamlIlNode>().Any()) |
|
|
|
|