Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Understanding Dependency Properties
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Understanding Dependency Properties
Miscellaneous
Thread ID:
01462451
Message ID:
01462451
Views:
134
I followed an article and put together this code example:
public partial class MyUserControl : UserControl
{
    public static readonly System.Windows.DependencyProperty CurrentTimeProperty =
            System.Windows.DependencyProperty.Register("CurrentTime", typeof(DateTime),
            typeof(MyUserControl), new FrameworkPropertyMetadata(DateTime.Now, 
                    OnCurrentTimePropertyChanged, 
                    OnCoerceCurrentTimeProperty ),
                    OnValidateCurrentTimeProperty);


    public DateTime CurrentTime
    {
        get { return (DateTime)GetValue(CurrentTimeProperty); }
        set { SetValue(CurrentTimeProperty, value); }
    }


    public MyUserControl()
    {
        InitializeComponent();
    }


    private static void OnCurrentTimePropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e)
    {
        MyUserControl control = source as MyUserControl;
        DateTime time = (DateTime)e.NewValue;
        
    }
    private static object OnCoerceCurrentTimeProperty(DependencyObject sender, object data)
    {
        if ((DateTime)data > DateTime.Now)
        {
            data = DateTime.Now;
        }
        return data;
    }
    private static bool OnValidateCurrentTimeProperty(object data)
    {
        return data is DateTime;
    }
}
The only part I'm still fuzzy on is this:
new FrameworkPropertyMetadata(DateTime.Now, 
                    OnCurrentTimePropertyChanged, 
                    OnCoerceCurrentTimeProperty ),
                    OnValidateCurrentTimeProperty);
The IntelliSense is cryptic. I see 11 overloads of the CTOR, and this is implementation 7. The IntelliSense doesn't show what/how
these methods are or give any real explanation.

I know my question is vauge, but can someone shed some more light on this?
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Next
Reply
Map
View

Click here to load this message in the networking platform