이 항목은 아직 평가되지 않았습니다.- 이 항목 평가

DependencyObject.GetLocalValueEnumerator 메서드

Creates a specialized enumerator for determining which dependency properties have locally set values on this DependencyObject.

네임스페이스: System.Windows
어셈블리: WindowsBase(windowsbase.dll)

public LocalValueEnumerator GetLocalValueEnumerator ()
public LocalValueEnumerator GetLocalValueEnumerator ()
public function GetLocalValueEnumerator () : LocalValueEnumerator
XAML에서 메서드를 사용할 수 없습니다.

반환 값

A specialized local value enumerator.

A local value is any dependency property value that was set by SetValue, as opposed to other aspects of the property system.

The LocalValueEnumerator obtained by calling GetLocalValueEnumerator can be used to enumerate properties that have a locally set value on a DependencyObject instance. Each such property is represented in the enumerator by a LocalValueEntry object, which has properties that reference the specific DependencyProperty and its values. This technique of enumerating over the locally set values can be used for optimization or for other handling of local values, such as to determine which property values of a DependencyObject would change if they were cleared.

중요:

The returned LocalValueEnumerator might contain LocalValueEntry records for dependency properties that are read-only, or that are property values that are calculated by the property system. For example, a visual framework element that has an established width will report a local value for ActualWidth. If you are getting local values in order to reset them, check the ReadOnly value on the property identifier first to verify that the DependencyProperty in question is not read-only.

The following example iterates all properties that have local values set on an object, then calls ClearValue to clear the values of each such property.

void RestoreDefaultProperties(object sender, RoutedEventArgs e)
{
    UIElementCollection uic = Sandbox.Children;
    foreach (Shape uie in uic)
    {
        LocalValueEnumerator locallySetProperties = uie.GetLocalValueEnumerator();
        while (locallySetProperties.MoveNext())
        {
            DependencyProperty propertyToClear = (DependencyProperty)locallySetProperties.Current.Property;
            if (!propertyToClear.ReadOnly) { uie.ClearValue(propertyToClear); }
        }
    }
}

Microsoft .NET Framework 3.0은 Windows Vista, Microsoft Windows XP SP2 및 Windows Server 2003 SP1에서 지원됩니다.

.NET Framework

3.0에서 지원
이 정보가 도움이 되었습니까?
(1500자 남음)

커뮤니티 추가 항목

추가
© 2013 Microsoft. All rights reserved.