Button Click Event

Here is small code to trigger button’s Click event using automation peer from source code :

if (button is Button)
{
ButtonAutomationPeer peer = new ButtonAutomationPeer((Button)button);

IInvokeProvider ip = (IInvokeProvider)peer;
ip.Invoke();
}

Trick will be used in upcoming article “Smart shortcut keys” for adding accessibility to silverlight applications.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s