정보
요청한 주제가 아래에 표시됩니다. 그러나 이 주제는 이 라이브러리에 포함되지 않습니다.

DependencyObject 클래스

Represents an object that participates in the dependency property system.

네임스페이스: System.Windows
어셈블리: WindowsBase(windowsbase.dll)
XML 네임스페이스:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

[TypeDescriptionProviderAttribute(typeof(DependencyObjectProvider))] 
public class DependencyObject : DispatcherObject
/** @attribute TypeDescriptionProviderAttribute(MS.Internal.ComponentModel.DependencyObjectProvider) */ 
public class DependencyObject extends DispatcherObject
TypeDescriptionProviderAttribute(MS.Internal.ComponentModel.DependencyObjectProvider) 
public class DependencyObject extends DispatcherObject
<DependencyObject .../>

The DependencyObject class enables Windows Presentation Foundation (WPF) property system services on its many derived classes.

The property system's primary function is to compute the values of properties, and to provide system notification about values that have changed. Another key class that participates in the property system is DependencyPropertyDependencyProperty enables the registration of dependency properties into the property system, and provides information about them, whereas DependencyObject enables objects to use the dependency properties.

DependencyObject services and characteristics include the following:

  • Dependency property hosting support. You register a dependency property by calling the Register method, and storing the method's return value as a public static field in your class.

  • Attached property hosting support. You register an attached property by calling the RegisterAttached method, and storing the method's return value as a public static readonly field in your class. (There are also additional member requirements; for details, see Attached Properties Overview).Your attached property can then be set on any class that derives from DependencyObject.

  • Get, set, and clear utility methods for values of any dependency properties that exist on the DependencyObject.

  • Metadata, coerce value support, property changed notification, and override callbacks for dependency properties or attached properties. Also, the DependencyObject class facilitates the per-owner property metadata for a dependency property.

  • A common base class for classes derived from ContentElement, Freezable, or Visual. (UIElement, the other core element class, is a deeper subclass of Visual.)

The following example derives from DependencyObject to create a new abstract class. The class then registers an attached property, and includes support members for that attached property.

public abstract class AquariumObject3 : DependencyObject
{
    public enum Bouyancy
    {
        Floats,
        Sinks,
        Drifts
    }
    public static readonly DependencyProperty BouyancyProperty = DependencyProperty.RegisterAttached(
      "Bouyancy",
      typeof(Bouyancy),
      typeof(AquariumObject3),
      new FrameworkPropertyMetadata(Bouyancy.Floats, FrameworkPropertyMetadataOptions.AffectsArrange),
      new ValidateValueCallback(ValidateBouyancy)
    );
    public static void SetBouyancy(UIElement element, Bouyancy value)
    {
        element.SetValue(BouyancyProperty, value);
    }
    public static Bouyancy GetBouyancy(UIElement element)
    {
        return (Bouyancy)element.GetValue(BouyancyProperty);
    }
    private static bool ValidateBouyancy(object value)
    {
        Bouyancy bTest = (Bouyancy) value;
        return (bTest == Bouyancy.Floats || bTest == Bouyancy.Drifts || bTest==Bouyancy.Sinks);
    }
}

System.Object
   System.Windows.Threading.DispatcherObject
    System.Windows.DependencyObject
       파생 클래스

이 형식의 모든 public static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

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

.NET Framework

3.0에서 지원

커뮤니티 추가 항목

표시:
© 2014 Microsoft