Edit
It bothers me for almost a year. I will update the answer and add a reward.
I have a user control that has a dependency property
public class Graph : Control { public List<Figure> Figures { get { return (List<Figure>)GetValue(FiguresProperty); } set { SetValue(FiguresProperty, value); } } public static readonly DependencyProperty FiguresProperty = DependencyProperty.Register("Figures", typeof(List<Figure>), typeof(Graph), new PropertyMetadata((d, e) => ((Graph)d).InvalidateVisual())); ... }
Figure - base class for all shapes:
public abstract class Figure { ... } public class LineFigure : Figure { ... } public class XGridFigure : Figure { ... } public class YGridFigure : Figure { ... } ...
Now, look at the screenshots below to see the problem: sometimes (after making changes to xaml elsewhere), the designer goes crazy and stops rendering the entire window, throwing exceptions , and the code compiles and runs without problems . I can close this xaml (designer) and open it again so that the problem goes away. But he always appears.
Question: Is something wrong on my part? Missing attribute? Improper use? How can I fix this problem?
Old question
The ugly situation.
I have 2 UserControl . In manual operation, Graph used. Graph has the Figures property to indicate List<Figure> . There are dozens of numbers that have Figure as a base.
In one UserControl it works fine, in case of other exception exceptions
The specified value cannot be assigned to the collection. The following was expected: "Figure".
And I do not see the difference, which can cause a problem.
Here is a problematic one screenshot

And here one works

Despite the errors, it compiles and runs the project, but if I need to make changes to the problematic UserControl , it will not show any content (says "Invalid markup"). The graphs are almost the same, all 8 errors are shown for only one UserControl .
What should I do? How to fix such errors? I rule out (completely) any problem with Graph , because it works without a single problem, and it works without problems for another UserControl . Problem with the designer of Visual Studio? Using 2013 Express for Windows Desktop.