littleBrain
littleBrain

Reputation: 169

WPF - Button click on selection within a limited time interval?

I have grid of button. I want to a button to be clicked(invoke click event) without any key press or mouse event.Just want it to be clicked automatically on selection within a limited time interval(3 secs).

Upvotes: 0

Views: 647

Answers (2)

Josh
Josh

Reputation: 69282

You can programmatically click a button using the automation interfaces in WPF. Of course if you were using commands instead of handling click events (highly recommended) then you could just invoke the command.

Here's the code for clicking a button using automation from Josh Smith's blog.

var peer = new ButtonAutomationPeer(someButton);
var invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;

invokeProv.Invoke();

Upvotes: 5

timothyclifford
timothyclifford

Reputation: 6969

You could use a Timer and invoke whatever you like on the Elapsed event?

// Create a timer with a three second interval.
myTimer = new System.Timers.Timer(3000);
myTimer.Elapsed += new ElapsedEventHandler(YourEventHere);
myTimer.Enabled = true;

Upvotes: 0

Related Questions