This topic has not yet been rated - Rate this topic

FreezableCollection<T> Class

Represents a collection of DependencyObject, Freezable, or Animatable objects. FreezableCollection<T> is itself an Animatable type.

Namespace:  System.Windows
Assembly:  PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
public class FreezableCollection<T> : Animatable, 
	IList, ICollection, IList<T>, ICollection<T>, IEnumerable<T>, 
	IEnumerable 
where T : DependencyObject
See Remarks.

Type Parameters

T

The type of collection. This type must be a DependencyObject or a derived class.

This class is provided to enable the creation of custom collection types that fully support data binding, change notification, property invalidation, and animation of its contents.

XAML Usage for FreezableCollection

FreezableCollection<T> supports a limited XAML syntax.

  • As an object element at the root, you can theoretically specify an unconstrained FreezableCollection<T> object element, which must also specify the x:TypeArguments Attribute to declare the constraint. However, this is not a common scenario, because to do this, the FreezableCollection<T> must be the root element. This limitation exists because the XAML processor implementation in WPF can only support x:TypeArguments Attribute when the element it is being set on is the root element, and you must use x:TypeArguments on any open constraint generic if you want to instantiate a generic type in XAML. It is unlikely that you want a FreezableCollection<T> as the root element, even as loose XAML.

  • If you derive from FreezableCollection<T> and apply a type constraint in the derived collection, the derived collection can support a variety of usages. This is possible because the constraint in your derivation eliminates the need to pass x:TypeArguments.

    • The typical XAML usage for such a derived collection is through implicit collection syntax. Collections that support certain interfaces do not need to specify the collection itself as an object element. For details on collection syntax in XAML, see XAML Syntax Terminology. For instance, an object with a property where the property was of type FreezableCollection<T> constrained by DependencyObject could support the following syntax:

      <object>
        <object.property>
          oneOrMoreDependencyObjectElements
        </object.property>
      </object>
      
    • As long as you do not hide the default constructor, the derived collection can also support an object element syntax (where the object element is explicit, as opposed to the implicit usage shown above). It does not need to be the root element. Or, you can also use the derived collection as a root element, without needing to specify x:TypeArguments, although using a collection as a root element is uncommon.

  • Any child elements of the collection in either of the above scenarios must be of the type of either the implemented constraint, or as specified by x:TypeArguments.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.