harvendra singh
What is Dependency property in WPF?
By harvendra singh in C# on Jul 28 2014
  • Ajay Gandhi
    Nov, 2015 20

    https://msdn.microsoft.com/en-us/library/aa581779.aspx

    • 0
  • Ajay Gandhi
    Nov, 2015 20

    Dependency properties are properties which provide a way to compute the value of a property based on the value of other inputs.

    • 0
  • Kml Surani
    Apr, 2015 15

    Dependency Properties Overview. Windows Presentation Foundation (WPF) provides a set of services that can be used to extend the functionality of a common language runtime (CLR) property.

    • 0
  • Munesh Sharma
    Oct, 2014 9

    http://www.c-sharpcorner.com/UploadFile/6d590d/wpf-dependency-property/

    • 0
  • Sunil Gaded
    Aug, 2014 28

    DependencyProperty are the properties which can be used in another control,Ex: i have a rectangle, Canvas.Right='100' Canvas.Left='200'here Canvas is the another contol,so we can use it in the rectangle

    • 0
  • Rajendra Tripathy
    Jul, 2014 30

    DependencyProperty :A dependency property is a property where the current value is dependent (hence the name) on other aspects such as default values, validation, coercion, value inheritance or animation. Also a depedency property has inbuilt support for change notifications, data binding and styling. The purpose of dependency properties is to provide a way to compute the value of a property based on the value of other inputs. These other inputs might include system properties such as themes and user preference, just-in-time property determination mechanisms such as data binding and animations/storyboards, multiple-use templates such as resources and styles, or values known through parent-child relationships with other elements in the element tree. In addition, a dependency property can be implemented to provide self-contained validation, default values, callbacks that monitor changes to other properties, and a system that can coerce property values based on potentially runtime information. Derived classes can also change some specific characteristics of an existing property by overriding dependency property metadata, rather than overriding the actual implementation of existing properties or creating new properties. How to create a DependencyProperty :To create a DependencyProperty, add a static field of type DepdencyProperty to your type and call DependencyProperty.Register() to create an instance of a dependency property. The name of the DependendyProperty must always end with ...Property. This is a naming convention in WPF. To make it accessable as a normal .NET property you need to add a property wrapper. This wrapper does nothing else than internally getting and setting the value by using the GetValue() and SetValue() Methods inherited from DependencyObject and passing the DependencyProperty as key. Important: Do not add any logic to these properties, because they are only called when you set the property from code. If you set the property from XAML the SetValue() method is called directly. If you are using Visual Studio, you can type propdp and hit 2x tab to create a dependency property.// Dependency Property public static readonly DependencyProperty CurrentTimeProperty = DependencyProperty.Register( "CurrentTime", typeof(DateTime),typeof(MyClockControl), new FrameworkPropertyMetadata(DateTime.Now));// .NET Property wrapper public DateTime CurrentTime {get { return (DateTime)GetValue(CurrentTimeProperty); }set { SetValue(CurrentTimeProperty, value); } }Each DependencyProperty provides callbacks for change notification, value coercion and validation. These callbacks are registered on the dependency property.

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS