Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Freezable.Clone() & Freezable.CloneCurrentValue() methods

Tags:

wpf

freezable

The documentation says

Clone- "Creates a modifiable clone of the System.Windows.Freezable, making deep copies of the object's values. When copying the object's dependency properties, this method copies expressions (which might no longer resolve) but not animations or their current values."

CloneCurrentValue- "Creates a modifiable clone (deep copy) of the System.Windows.Freezable using its current values."

It means both do deep copy. Then what is the difference?

like image 833
Nitesh Avatar asked Jun 19 '26 20:06

Nitesh


1 Answers

If I understand the documentation correctly, Clone also copies the binding expressions. So if a property of the object is bound, it remains bound in the copy.

CloneCurrentValues, on the other hand, only copies the current values, as the name implies. Bindings are not kept, so the values in the copy won't be updated if the source of the binding is modified.

like image 82
Thomas Levesque Avatar answered Jun 24 '26 15:06

Thomas Levesque



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!