Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
715
XamMaskedEditor throwing an exception on AutomationElement.SetFocus()
posted

I need to focus XamMaskedEditor through Automation.

I have an XamMaskedEditor with AutomationID="xme1".

AutomationElement xme1 = library.GetElement(mainWindow, AutomationElement.AutomationIdProperty, "xme1"TreeScope.Descendants);
xme1.SetFocus();

While executing the second statement, an exception is thrown.

The target element cannot receive focus.
   at MS.Internal.Automation.ElementUtil.Invoke(AutomationPeer peer, DispatcherOperationCallback work, Object arg)

Call Stack:
>    UIAutomationClient.dll!MS.Internal.Automation.UiaCoreApi.CheckError(int hr) Line 1223    C#
     UIAutomationClient.dll!System.Windows.Automation.AutomationElement.SetFocus() Line 916 + 0x21 bytes    C#
     CalculatorTest.exe!CalculatorTest.TestCalc.StartTest() Line 26 + 0xa bytes    C#
     CalculatorTest.exe!CalculatorTest.Program.Main(string[] args) Line 14 + 0x1d bytes    C#


Please help me with this issue.


Parents Reply Children
No Data