Gets a value that indicates whether the dependency property identified by this DependencyProperty instance is a read-only dependency property.
Assembly: WindowsBase (in WindowsBase.dll)
Read-only dependency properties are registered within the property system by calling the RegisterReadOnly method as opposed to the Register method. Attached properties can also be registered as read-only; see RegisterAttachedReadOnly.
Read-only dependency properties require a DependencyPropertyKey identifier rather than a DependencyProperty identifier to perform metadata operations such as overriding the metadata or setting the value. If you obtained a collection of DependencyProperty identifiers through a call to GetLocalValueEnumerator or another API that exposes identifiers, check the value before attempting to call SetValue or OverrideMetadata using that dependency property identifier as an input parameter, to verify that the dependency property that the identifier represents is not read-only. If the value of is true on a dependency property, there is no programmatic way to obtain a reference to the DependencyPropertyKey identifier of that dependency property, from the metadata or from the DependencyProperty identifier; the identifier must be available as a static field in order to call SetValue(DependencyPropertyKey, Object) against a read-only dependency property.
When you create a custom dependency property, and register it as read-only, you should define only a get accessor for the CLR wrapper property. Otherwise, your class will have a confusing object model for the property wrapper as compared to the access to the backing dependency property. For details, see Custom Dependency Properties or Read-Only Dependency Properties.
The following example obtains the default metadata and the dependency property identifier properties from various dependency property fields, and uses the information to populate a table to implement a "metadata browser".
pm = dp.GetMetadata(dp.OwnerType); MetadataClass.Text = pm.GetType().Name; TypeofPropertyValue.Text = dp.PropertyType.Name; DefaultPropertyValue.Text = (pm.DefaultValue!=null) ? pm.DefaultValue.ToString() : "null"; HasCoerceValue.Text = (pm.CoerceValueCallback == null) ? "No" : pm.CoerceValueCallback.Method.Name; HasPropertyChanged.Text = (pm.PropertyChangedCallback == null) ? "No" : pm.PropertyChangedCallback.Method.Name; ReadOnly.Text = (dp.ReadOnly) ? "Yes" : "No";
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.