PropertyMetadata.IsSealed Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets a value that determines whether the metadata has been applied to a property in some way, resulting in the immutable state of that metadata instance.
protected:
property bool IsSealed { bool get(); };
protected bool IsSealed { get; }
member this.IsSealed : bool
Protected ReadOnly Property IsSealed As Boolean
Property Value
true
if the metadata instance is immutable; otherwise, false
.
Examples
The following example checks IsSealed prior to a set operation of a custom metadata property.
public Boolean SupportsMyFeature
{
get { return _supportsMyFeature; }
set { if (this.IsSealed != true) _supportsMyFeature = value; } //else may want to raise exception
}
protected override void Merge(PropertyMetadata baseMetadata, DependencyProperty dp)
{
base.Merge(baseMetadata, dp);
MyCustomPropertyMetadata mcpm = baseMetadata as MyCustomPropertyMetadata;
if (mcpm != null)
{
if (this.SupportsMyFeature == false)
{//if not set, revert to base
this.SupportsMyFeature = mcpm.SupportsMyFeature;
}
}
}
Remarks
Various properties of PropertyMetadata, such as DefaultValue, are defined in the object model as read-write. This is so those properties can be adjusted after initialization of the PropertyMetadata object itself. However, once the metadata is applied to a dependency property as part of a call to Register, AddOwner, or OverrideMetadata, the property system will seal that metadata instance and the properties are now considered immutable. At the time of one of these calls, OnApply is called, and the value of this property is set to true
.
Applies to
See also
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기