All the books I read on Silverlight indicate that a dependency property's getter and setter should look like:
public bool IsReadOnly
{
get { return (bool) GetValue(TextBox.IsReadOnly);}
set { SetValue(TextBox.IsReadOnly, value);}
}
However, when I look in Visual Studio at the definition of the TextBox class, I see for the dependency property IsReadOnly the following code:
public bool IsReadOnly {
get; set; }
This appears to be using the "auto-implemented property" definition, which creates for us a hidden private variable, e.g. bool m_IsReadOnly. However, this is not what a dependency property needs, as seen from the first example. Therefore, does the compiler
check to see whether an auto-implemented property is a dependency property and if so, generate the "correct" code? Thanks for your help.