开发者

Deriving from Binding class (Silverlight 4.0)

开发者 https://www.devze.com 2023-02-05 05:06 出处:网络
Using the existing Binding class, we can write, <TextBox Text=\"{Binding Email, Mode=TwoWay}\"/>

Using the existing Binding class, we can write,

 <TextBox Text="{Binding Email, Mode=TwoWay}"/>

So we can write anything as Email; there is no validity check by Binding itself. I started writing a class BindingMore deriving from Binding so that eventually I could write,

 <TextBox Text="{local:BindingMore Email, Validate=SomeMethod, Mode=TwoWay}"/>

Where SomeMethod is some ICommand or delegate which will be triggered to validate the Email . That is my objective, and I've not written that yet.

As of now, I've written just this code,

public class BindingMore : System.Windows.Data.Binding
{
    public BindingMore() :开发者_JAVA百科 base() 
    { 
    }
    public BindingMore(string path) : base(path)
    {
    }
}

So, at this stage, BindingMore is exactly equivalent to Binding, yet when I write

 <TextBox Text="{local:BindingMore Email, Mode=TwoWay}"/>

It's giving me runtime error. But when I write,

 <TextBox Text="{local:BindingMore Path=Email, Mode=TwoWay}"/>

It's working fine. Can anybody tell me why it's giving runtime error in the first case?

Unfortunately, the error is not shown. All it shows is this:

Deriving from Binding class (Silverlight 4.0)

Also, I get the following error message from XAML (even when it builds perfectly and runs (in the second case)):

Type 'local:BindingMore' is used like a markup extension but does not derive from MarkupExtension.


Custom Markup Extensions are not supported in Silverlight. Try using an Attached Property approach or a Behavior.

0

精彩评论

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