WPF - Button click on selection within a limited time interval?
I have grid of button. I want to a button to be clicked(invoke cli开发者_运维知识库ck event) without any key press or mouse event.Just want it to be clicked automatically on selection within a limited time interval(3 secs).
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();
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;
精彩评论