February 2017
Intermediate to advanced
568 pages
14h 19m
English
We've already seen some examples of Dependency Properties in previous chapters, but now let's take a more thorough look. We have a large number of options that we can use when declaring these properties, some more commonly used than others. Let's investigate the standard declaration first, by defining an Hours property of type int in a class named DurationPicker.
public static readonly DependencyProperty HoursProperty =
DependencyProperty.Register(nameof(Hours), typeof(int),
typeof(DurationPicker));
public int Hours
{
get { return (int)GetValue(HoursProperty); }
set { SetValue(HoursProperty, value); }
}
As with all Dependency Properties, we start by declaring the property as static and readonly, because we only want a single, ...