Friday, 5 July 2013

WPF Dependcy Property

To create a Dependency property .

DependencyProperty is set to enable declarative code to alter the properties of an object which reduces the data requirements by providing a more powerful notification system regarding the change of data in a very specific way. In .NET, there are two types of properties: the normal property, and a Dependency Property which adds functionality over the normal property.



 




// Dependency Property
public static readonly DependencyProperty FirstNameProperty = 
     DependencyProperty.Register( "FirstName", typeof(String),
     typeof(classname), new FrameworkPropertyMetadata());



 

// .NET Property wrapper
public string FirstName
{
    get { return (string)GetValue(FirstNameProperty); }
    set { SetValue(FirstNameProperty, value); }
}

No comments:

Post a Comment