相关疑难解决方法(0)

未调用DependencyProperty getter/setter

我正在尝试创建一个从标准网格派生的自定义控件.我添加了一个ObservableCollection作为Custom控件的DependencyProperty.但是,永远不会达到它的get/set.我可以在创建与ObservableCollection一起正常工作的DependencyProperty时有一些指导吗?

public class MyGrid : Grid
{
    public ObservableCollection<string> Items
    {
        get
        {
            return (ObservableCollection<string>)GetValue(ItemsProperty);
        }
        set
        {
            SetValue(ItemsProperty, value);
        }
    }

public static  DependencyProperty ItemsProperty =
                DependencyProperty.Register("Items", typeof(ObservableCollection<string>), 
        typeof(MyGrid), new UIPropertyMetadata(null, OnItemsChanged));

}
Run Code Online (Sandbox Code Playgroud)

wpf grid dependency-properties

4
推荐指数
1
解决办法
3572
查看次数

标签 统计

dependency-properties ×1

grid ×1

wpf ×1