I created a WPF application. It works completely fine on desktops but the moment the application is ran on a touchscreen it crashes. I've turned off touchscreen processes and the application worked completely fine. I'm wondering has anyone found a "better" fix than to disable touchscreen processes, as this would not work on the microsoft surface or and windows tablet.
I'm currently using .Net 4.5
I have had many problems with WPF
AutomationPeer
too.You might be able to solve your problem by forcing your WPF UI elements to use a custom AutomationPeer that behaves differently to the default one by not returning AutomationPeers of child controls. This might stop any UI automation stuff working, but hopefully in your case, as in mine, you are not using UI automation..
Create a custom automation peer class that inherits from
FrameworkElementAutomationPeer
and overrides theGetChildrenCore
method, to return an empty list instead of the child control automation peers. This should stop problems occuring when something attempts to iterate through the tree of AutomationPeers.Also override the
GetAutomationControlTypeCore
to specify the control type that you will use the automation peer on. In this example I am passing theAutomationControlType
as a constructor parameter. If you apply your custom automation peer to your Windows it should solve your problems as I think the root element is used to return all children.To use the custom automation peer override the
OnCreateAutomationPeer
method in your UI element e.g. Window: