Wednesday, 2 October 2013

How to click a button programmatically in Windows Phone

How to click a button programmatically in Windows Phone

I have a Button on my app screen and I want to test its functionality in
various test cases by programmatically invoking the click event. For
Windows Phone SDK there is no button1.PerformClick() that I can call. I am
getting the button by traversing the Visual Tree; so, I have no access to
the event handler subscribed to the Click event of that button. I need to
somehow get the event handler delegate, subscribed to the event and then
invoke that event handler like this eventHandler.Invoke(button,
EventArgs.Empty).
Does anyone know how I can get the event handler delegate?

No comments:

Post a Comment