I have a class that represents a container and a class that represents things that can go in that container, as well as a user control that displays that container and a user control that displays things that can go in that container, something like
public class MyContainer
{
public MyThing Thing1
{
get { return thing1; }
set
{
if (thing1 != value)
{
thing1 = value;
OnPropertyChanged("Thing1");
}
}
}
}
<UserControl x:Class="MyContainerControl"
...
<Grid x:Name="LayoutRoot">
...
<ctl:MyThingControl DataContext="{Binding Thing1}" />
...
</Grid>
</UserControl>
The Designer complains about {Binding Thing1}
with the error message
unable to cast object of type 'Microsoft.Expression.Platform.Silverlight.InstanceBuilders.SilverlightBindingWrapper' to type 'MyThing'
However, if I set the data context in code开发者_运维百科 behind, everything works fine.
What does this error mean, and how can I resolve the data binding issue?
精彩评论