WPF: Is clone of Freezable frozen?

WPF defines a Freezable type that is a base class for “almost immutable” objects. They can be setup in read/write mode and then “frozen” which makes them immutable and thread safe.

Freezables are also cloneable. If I make a clone of a Freezable, will it be frozen? Fortunately, it won’t, so I can modify the clone at will, and then freeze it if necessary. Here’s the passing unit test that proves that:


   [TestMethod]
   public void ClonedFreezableIsNotFrozen()
   {
      var brush = new SolidColorBrush(Colors.Red);
      brush.Freeze();
      var clone = brush.Clone();
      Assert.IsFalse(clone.IsFrozen);
   }

1 Comment


Leave a Reply

Your email address will not be published. Required fields are marked *