Click here to Skip to main content
13,901,292 members
Rate this:
Please Sign up or sign in to vote.
See more:
1.I crate a button using TouchDown and TouchUp event,code as:

forwardButton.AddHandler(Button.TouchDownEvent, new RoutedEventHandler(touch_down_F), true);

2.and the calling method as:

private void touch_down_F(object sender, RoutedEventArgs e)
            } there any wrong exits? it has no response.....

What I have tried:

just as said.
tool is VS2017 in windows7.
hardware is touchscreen with 5-wire resistive touch control.
Updated 14-Jan-19 0:45am
Gerry Schmitz 12-Jan-19 12:39pm
The amount of help you get is directly proportional to the amount of information you supply. For all we know, your "5-wire resistive touch control" is not "plugged in".
Member 14102420 14-Jan-19 0:49am
what i want to do is to achieve the function of MouseDown and MouseUp of a button without mouse.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

For WPF:

0) Add a reference to UIAutomationProvider

1) Include these usings:
using System.Windows.Automation.Peers; 
using System.Windows.Automation.Provider;
3) put this code in the appropriate place:
ButtonAutomationPeer peer = new ButtonAutomationPeer(forwardButton);
IInvokeProvider invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;
or if you want the code on a single line:
((IInvokeProvider) (new ButtonAutomationPeer(someButton).GetPattern(PatternInterface.Invoke)).Invoke();
Member 14102420 17-Jan-19 2:26am
using System.Windows.Automation.Provider;
it seems System.Windows.Automation don't include Provider.
Member 14102420 18-Jan-19 20:04pm
it shows System.Windows.Automation don't include Provider.what's the matter?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web02 | 2.8.190306.1 | Last Updated 14 Jan 2019
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100