Deriving from Binding class (Silverlight 4.0)
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:
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
.
精彩评论