不包含'SetValue&的定义的GetValue”

时间:2016-10-12 06:09:19

标签: c# wpf wpf-controls dependency-properties

public partial class MainWindow : Window 
{ 
    public static readonly DependencyProperty PointsCollectionProperty = DependencyProperty.Register("PointsCollection", typeof(PointsCollection), typeof(MainWindow), new PropertyMetadata()); 

    public PointsCollection PointsCollection 
    { 
     get { return (PointsCollection) GetValue(PointsCollectionProperty); } 
     set { SetValue(PointsCollectionProperty, value); } 
    } 

    public MainWindow() 
    { 
        InitializeComponent(); 
        PointsCollection = new PointsCollection(); 
        PointsCollection.Add(new Point(1, 1)); 
        PointsCollection.Add(new Point(2, 2)); 
        PointsCollection.Add(new Point(3, 3)); 
    } 
    void Button_Click(object sender, RoutedEventArgs e) 
    { 
        PointsCollection.Add(new Point(1, 1)); 
    } 
} 

public class PointsCollection : ObservableCollection<Point> 
{ 
}

不包含SetValue & GetValue的定义。在上面的依赖项属性中获取错误。

0 个答案:

没有答案