MVS无法识别SetValue()和GetValue()

时间:2019-02-03 21:31:36

标签: c# wpf oop dependency-properties dependencyobject

因此,我正在尝试制作wpf日历,但是GetValue()和SetValue()方法有问题。我已经声明了所有库,并向我表明这些方法根本不存在并且无法识别。

    using System;
    using System.Collections.ObjectModel;
    using System.ComponentModel;
    using System.Windows;
    using System.Windows.Controls;
    using System.Reflection;


    namespace CustomControls
    {
       public class Calendar : Control
        {
            public ObservableCollection<Day> Days { get; set; }
            public ObservableCollection<string> DayNames { get; set; }
            public static readonly DependencyProperty CurrentDateProperty = DependencyProperty.Register("CurrentDate", typeof (DateTime), typeof (Calendar));

            public event EventHandler<DayChangedEventArgs> DayChanged;

            public DateTime CurrentDate
            {
                get { return (DateTime) GetValue(CurrentDateProperty); }
                set { SetValue(CurrentDateProperty, value); }
            }
        }
}

希望您能帮助我并提前谢谢您!

0 个答案:

没有答案