开发者

Silverlight 4 Binding and SilverlightBindingWrapper

开发者 https://www.devze.com 2023-04-03 17:31 出处:网络
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 thi

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消