Freezable.CloneCurrentValue Method
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.
Creates a modifiable clone (deep copy) of the Freezable using its current values.
public:
System::Windows::Freezable ^ CloneCurrentValue();
public System.Windows.Freezable CloneCurrentValue ();
member this.CloneCurrentValue : unit -> System.Windows.Freezable
Public Function CloneCurrentValue () As Freezable
A modifiable clone of the current object. The cloned object's IsFrozen property is false
even if the source's IsFrozen property is true
.
The Clone and CloneCurrentValue methods produce modifiable clones of frozen Freezable objects (the methods also clone Freezable objects that are not frozen). The clone is effectively a deep copy of the current object.
The following table summarizes the differences between the Clone and CloneCurrentValue methods.
Action | Clone method behavior | CloneCurrentValue method behavior |
---|---|---|
Copying a dependency property that has an expression | The expression is copied, but might no longer resolve. For more information, see Freezable Objects Overview. | The current value of the expression is copied, but not the expression itself. |
Copying an animated dependency property | The property's base (non-animated) value is copied. Animations are not copied. | The property's current animated value is copied. Animations are not copied. |
Note that unset properties are not copied. If an unset property has a default value that is a frozen Freezable, that property value remains frozen in the otherwise modifiable clone.
This method can be useful for moving a Freezable between threads. First, make the Freezable unmodifiable by using its Freeze method. Now another thread can access the Freezable and make a local clone that it can access.
This method uses the CloneCurrentValueCore(Freezable) method to produce the clone; Freezable implementers who override CloneCurrentValueCore(Freezable) must ensure that the copy is not frozen on creation.
Product | Versions |
---|---|
.NET Framework | 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: