There is a certain user control. It has a property with a collection of elements of type abstract class MyClass : DependencyObject

There are several inheritors of this class (for example, MyClassEx : MyClass )

So, when I add a new element to the collection in the xaml markup

 <MyControl> <MyControl.SomeCollection> <MyClassEx/> </MyControl.SomeCollection> </MyControl> 

then when all the rules are started, but in the designer mode <MyClassEx/> underlined and when hovering it goes "The specified value cannot be assigned to the collection. The following type is required:" MyClass ".

It is a bit annoying. tell me how to cure? Maybe what attribute is needed for the collection so that xaml allows to use successors in the collection painlessly?

  • And what kind of SomeCollection ? - VladD
  • @VladD, SomeCollection : DependencyObject, INotifyCollectionChanged, IList, IList<MyClass> - iRumba
  • Hm And if you try to add the attribute [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] ? - VladD
  • @VladD, hmm .... cured by deleting the DependencyObject type from the SomeCollection type SomeCollection . I don’t know why ... I don’t have time to figure it out, but if you find a reason, please reply to it - iRumba
  • @VladD, the error came out ... The end of the working day and all that ... tired out. In general, the collection type is ObservableCollection<MyClass> . - iRumba

0