c# - The specified value cannot be assigned to the collection -
edit
This will update my bug for almost one year and add reward to me.
I have a custom control, which has the dependency property
public class graph: control {public list & lt; Figure & gt; Get the stats {return (list (list (lt; figure & gt;) GetValue (dataproperty);} set {set valley (statistics property, value);}} public static read only dependency property statistics property = dependency property. Statistics ", typef (list & lt; Figure & gt;), typef (graph), new property matadata ((D, E) = & gt; (graph) d) illegal valid ())); ...}
Figure
is the base class for all the data:
public abstract class shape {...} Public class linefigure: Figure {...} Public class XGridFigure: Figure {...} Public class YGridFigure: Figure {...} ...
Now look at the screenshot below problem See: Sometimes (after making changes in xaml to second place) the designer goes crazy about it and throwing an exception, compiles the code and runs without problems . I can stop this XML (designer) and open it again to correct the problem. But it always looks again.
Question: Is there anything wrong with my side? Missing attribute? Misuse? How can I fix that problem?
old question
ugly situation.
I have 2 UserControl
. graph
is used in both hand-held control list & lt; Figure & gt;
is the property of graph
to define statistics
. There are dozens of figures that have the figure
basis.
This works fine in a UserControl
, in other throws exceptions
can not be assigned assigned value collection. The following types of expectations were: "Figure".
And I do not make any difference which can cause a problem.
There is a problem screenshot
And here one is working
Despite the error project compile and run, but if I am correcting the problematic UserControl
, then it is not displaying any content (says "invalid markup") Is similar, all the 8
errors are shown for just one UserControl
.
What should I do? How to troubleshoot such errors? I extract (completely) any problem with graph
because it runs without a single problem and it works for any other UserControl
without problem Does Visual Studio Designer Problems? Use of 2013 Express for Windows Desktop
In fact, the visual designer has inherited the figure
. Use of ILIT as the interface type is a solution:
Public IELIST data {Return (IELIT) Gateville (dataproperty); } Set {set valley (statistics property, value); }} Public Static Read Only Dependency Property Statistics = DependencyProperty.Register ("Figures", Typef (ILISIS), Typef (Graph), New Property Metadata (New List & Objects; Object) ());
This may look a bit awkward (because you leave type protection) but look closely at WPF classes. They all do so (most likely for good reasons) or WPF also creates collection codes such as PathFigureCollection
which both IList
and IList
Comments
Post a Comment