Click here to Skip to main content
15,911,315 members
Please Sign up or sign in to vote.
1.00/5 (1 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)
            {
                content;
            }

3.is 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.
Posted
Updated 14-Jan-19 0:45am
Comments
[no name] 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".
Panda United 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

For WPF:

0) Add a reference to UIAutomationProvider

1) Include these usings:
C#
using System.Windows.Automation.Peers; 
using System.Windows.Automation.Provider;
3) put this code in the appropriate place:
C#
ButtonAutomationPeer peer = new ButtonAutomationPeer(forwardButton);
IInvokeProvider invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;
invokeProv.Invoke();
or if you want the code on a single line:
C#
((IInvokeProvider) (new ButtonAutomationPeer(someButton).GetPattern(PatternInterface.Invoke)).Invoke();
 
Share this answer
 
v2
Comments
Panda United 17-Jan-19 2:26am    
using System.Windows.Automation.Provider;
it seems System.Windows.Automation don't include Provider.
Panda United 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900