Is there anyone who knows this?
I have been trying this for the last week, and no luck.
Now I can see that once can bind successfully to a Button's Text property, but not its ImageKey property:
myButton.Text = "new text"; // really changes the bound data
myButton.ImageKey = "new text"; // does NOT change the bound data
I use:
myButton.DataBindings.Add ( new Binding ( "ImageKey", this.MyData, "Name", true, DataSourceUpdateMode.OnPropertyChanged ) );
Why? What makes the Binding tick/work? I just don't get it.
EDIT:
OK so I defined these for my own derived control:
public event EventHandler ImageKeyChanged;
protected virtual void OnImageKeyChanged ( EventArgs e )
{
if ( ImageKeyChanged!= null )
{
ImageKeyChanged ( this, e );
}
}
[Bindable ( true )]
public new string ImageKey
{
get
{
return base.ImageKey;
}
set
{
base.ImageKey = value;
this.OnImageKeyChanged ( EventArgs.Empty );
}
}
It still doesn't work. Is there a tutorial or something on the net, that shows this. It just doesn't work for me.