2011-04-08 69 views
5

我正在为WPF和Silverlight定制控件。这种控制具有复杂类型的集合属性,它是抽象的,就像这样:Visual Studio 2010设计时间集合编辑器

public Collection<MyBase> Configuration 
    { 
     get { return (Collection<MyBase>)GetValue(ConfigurationProperty); } 
     set { SetValue(ConfigurationProperty, value); } 
    } 

    // Using a DependencyProperty as the backing store for Configuration This enables animation, styling, binding, etc... 
    public static readonly DependencyProperty ConfigurationProperty = 
     DependencyProperty.Register("Configuration", typeof(Collection<MyBase>), typeof(MyControl), new PropertyMetadata(new ObservableCollection<MyBase>())); 

我的问题是,我不能将新项目添加到这个属性在Visual Studio 2010的设计,因为它不知道任何派生类型的MyBase。

是否有任何方法向设计师注册这些类型?编辑器可以正常使用现有的项目,并且可以删除和修改它们。图片说明:

enter image description here

回答

5

您需要与NewItemTypesAttribute来装饰您的收藏属性。你可以直接在你的类中做到这一点,但在WPF/Silverlight中,这些通常是在单独的设计程序集中定义的。有这个here好走。

相关问题