LocalValueEnumerator 结构


DependencyObject 上存在的任何依赖属性的本地值提供枚举支持。Provides enumeration support for the local values of any dependency properties that exist on a DependencyObject.

public value class LocalValueEnumerator : System::Collections::IEnumerator
public struct LocalValueEnumerator : System.Collections.IEnumerator
type LocalValueEnumerator = struct
    interface IEnumerator
Public Structure LocalValueEnumerator
Implements IEnumerator


本地值 是依赖属性的值,该属性通过调用 SetValue ,或更常见地通过使用在内部调用的 CLR 属性包装的 set 访问器来设置依赖属性 SetValueA local value is a value for a dependency property that was set directly on a dependency property, by calling SetValue, or more typically by using the set accessor of a CLR property wrapper that calls SetValue internally. 其他不是本地值的属性系统 qps 的示例是通过样式或依赖属性默认值设置的值。Examples of other property system determinants that are not local values are values set through styles, or dependency property default values. 有关详细信息,请参阅依赖属性值优先级For details, see Dependency Property Value Precedence.

LocalValueEnumeratorGetLocalValueEnumerator 方法返回,并实现 IEnumerator 接口。A LocalValueEnumerator is returned by the GetLocalValueEnumerator method and implements the IEnumerator interface. 公共 LocalValueEnumerator 构造函数不存在; 因此,必须调用 GetLocalValueEnumerator 才能获取此类的实例。A public LocalValueEnumerator constructor does not exist; therefore, you must call GetLocalValueEnumerator to obtain an instance of this class.

SetValue ClearValue 在枚举本地值时,不要通过调用或) 来修改本地值 (。Do not modify local values (by calling SetValue or ClearValue) while enumerating local values. 如果基于枚举器返回的属性更改或清除属性值,则更改或清除操作不会使枚举器集合失效,因为许多实现情况都是如此 IEnumeratorIf you change or clear the property values based on properties that are returned by the enumerator, the change or clear operations do not invalidate the enumerator collection, as is the case for many IEnumerator implementations. 此外,枚举器视图也是一个快照。Also, the enumerator view is a snapshot. 不能保证对集合的更改是线程安全的,并且不会强制实施锁。A change to the collection is not guaranteed to be thread safe, and no lock is enforced. 其他线程仍可以从枚举数以外的上下文中免费访问本地值。Other threads still have free access to the local values from a context other than the enumerator.

如果你在类中具有一些操作,需要知道某个属性的值是否来自本地值,请使用此类型。Use this type if you have operations in your class where it is important to know whether a property's value came from a local value. 例如,在实现中使用此类型 OnPropertyChanged ,或在要查询所有本地设置属性的元数据的位置使用此类型。For example, use this type in an OnPropertyChanged implementation, or where you want to query the metadata on all locally set properties.



获取在集合中表示的项数。Gets the number of items that are represented in the collection.


获取集合中的当前元素。Gets the current element in the collection.



确定提供的 LocalValueEnumerator 是否等效于此 LocalValueEnumeratorDetermines whether the provided LocalValueEnumerator is equivalent to this LocalValueEnumerator.


返回当前 LocalValueEnumerator 的哈希代码。Returns a hash code for the current LocalValueEnumerator.


将枚举数推进到集合的下一个元素。Advances the enumerator to the next element of the collection.


将枚举数设置为其初始位置,该位置位于集合中第一个元素之前。Sets the enumerator to its initial position, which is before the first element in the collection.


Equality(LocalValueEnumerator, LocalValueEnumerator)

比较两个指定的 LocalValueEnumerator 对象是否相同。Compares whether two specified LocalValueEnumerator objects are the same.

Inequality(LocalValueEnumerator, LocalValueEnumerator)

比较两个指定的 LocalValueEnumerator 对象,以确定它们是否不相同。Compares two specified LocalValueEnumerator objects to determine whether they are not the same.



有关此成员的说明,请参见 CurrentFor a description of this members, see Current.