Possible Duplicate:
When to use Dependency Properties
i read about WPF dependency property but just could not understand it well what is dependency property and why it is required. when to use dependency property i means what kind of situation one should go for dependency property.
here is a sample code for dependency property
public static readonly DependencyProperty IsSpinningProperty =
DependencyProperty.Register(
"IsSpinning", typeof(Boolean),
);
public bool IsSpinning
{
get { return (bool)GetValue(IsSpinningProperty); }
set { SetValue(IsSpinningProperty, value); }
}
please help me to understand the dependency property with a easy sample code and also show me how application will be benifited. when it is required etc.
thanks
Simply put, a dependency property is used when it is involved in data binding (probably in some XAML code), or if you want that property to be set in XAML. It has significant overhead in comparison to regular C# properties, so if you don’t need it, stick to regular properties.