Question

I am just following the code examples of a Beginning SilverLight book and here is part of the code about user controls and Dependeny Property that I have typed from the book into my IDE:

    public class CoolDownButtonControl: Control
    {
        public static readonly DependencyProperty CoolDownSecondsProperty =
            DependencyProperty.Register(
                "CoolDownSeconds",
                typeof(int),
                typeof(CoolDownButtonControl),
                new PropertyMetadata(
                    new PropertyChangedCallback(
                        CoolDownButtonControl.OnCoolDownSecondsPropertyChanged
                    )
               )
            );

        public int CoolDownSeconds
        {
            get
            {
                return (int)GetValue(CoolDownSecondsProperty);
            }

            set
            {
                SetValue(CoolDownSecondsProperty, value);
            }
        }

        private static void OnCoolDownSecondsPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            CoolDownButtonControl cdBuutton = d as CoolDownButtonControl;
            cdBuutton.OnCoolDownButtonChange(null);
        }
}

The problem is that IDE highlights the line of cdBuutton.OnCoolDownButtonChange(null); complaining about

CoolDownButtonControl does not contain a definition for OnCoolDownButtonChange

As I am new to this and hoping to learn it from this example I couldn't figure out what is wrong and how to fix it?

Was it helpful?

Solution

You should add that method too, something like this:

protected virtual void OnCoolDownButtonChange(RoutedEventArgs e)
{

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top