// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
namespace Perspex
{
///
/// An attached perspex property.
///
/// The type of the property's value.
public class AttachedProperty : StyledPropertyBase
{
///
/// Initializes a new instance of the class.
///
/// The name of the property.
/// The class that is registering the property.
/// The property metadata.
/// Whether the property inherits its value.
public AttachedProperty(
string name,
Type ownerType,
StyledPropertyMetadata metadata,
bool inherits = false)
: base(name, ownerType, metadata, inherits)
{
}
///
public override bool IsAttached => true;
///
/// Attaches the property as a non-attached property on the specified type.
///
/// The owner type.
/// The property.
public StyledProperty AddOwner() where TOwner : IPerspexObject
{
var result = new StyledProperty(this, typeof(TOwner));
PerspexPropertyRegistry.Instance.Register(typeof(TOwner), result);
return result;
}
}
}