A cross-platform UI framework for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

27 lines
897 B

using Avalonia.Media;
#nullable enable
namespace Avalonia
{
/// <summary>
/// Extensions for <see cref="AvaloniaProperty"/>.
/// </summary>
public static class AvaloniaPropertyExtensions
{
/// <summary>
/// Checks if values of given property can affect rendering (via <see cref="IAffectsRender"/>).
/// </summary>
/// <param name="property">Property to check.</param>
public static bool CanValueAffectRender(this AvaloniaProperty property)
{
var propertyType = property.PropertyType;
// Only case that we are sure that property value CAN'T affect render are sealed types that don't implement
// the interface.
var cannotAffectRender = propertyType.IsSealed && !typeof(IAffectsRender).IsAssignableFrom(propertyType);
return !cannotAffectRender;
}
}
}