Click here to Skip to main content
13,828,588 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 yesterday
Gerry Schmitz 3 days ago
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 yesterday
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();

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
Web01 | 2.8.190114.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