开发者

Getting Error Invalid Binding Path in SIlverlight

I have an class say class A :

[DataContract]
public class A
{
    [DataMember]
    public string Name{ get; set; }
}

I am inheriting class A in class B :

[DataContract]
public class B : A
{
    public B()
    {
        Name = "Me"
    }
}

And in UI section I bind an object of class B to some control and i set the binding of this control as below 开发者_运维问答:

//This code throws an error :Invalid Error

Binding = new Binding{Path = new PropertyPath(objectB.Name),Mode = BindingMode.TwoWay}

Edit : The value of that property is Guid . So is the "-" in Guid causing the error ?


new PropertyPath(objectB.Name)

should be

new PropertyPath("Name")

and set

Source = objectB

So, it should be:

Binding = new Binding
          { 
              Source = objectB, 
              Path = new PropertyPath("Name"),
              Mode = BindingMode.TwoWay
          }
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜