Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
 IsSealed Property
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
PropertyMetadata..::.IsSealed Property

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.

Namespace:  System.Windows
Assembly:  WindowsBase (in WindowsBase.dll)
Visual Basic (Declaration)
Protected ReadOnly Property IsSealed As Boolean
Visual Basic (Usage)
Dim value As Boolean

value = Me.IsSealed
C#
protected bool IsSealed { get; }
Visual C++
protected:
property bool IsSealed {
    bool get ();
}
JScript
protected function get IsSealed () : boolean
XAML
You cannot set this property in XAML.

Property Value

Type: System..::.Boolean
true if the metadata instance is immutable; otherwise, false.

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.

The following example checks IsSealed prior to a set operation of a custom metadata property.

C#
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;
        }
    }
}

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker