我遇到了 ValuePattern 的问题。我有以下代码:
ValuePattern valuePattern = null;
try
{
valuePattern = AElement.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern;
valuePattern.SetValue(EditableElement.value[0].ToString());
Debug.WriteLine(AElement.Current.Name + "'s value changed to {0}.", EditableElement.value[0].ToString());
}
catch (InvalidOperationException)
{
Debug.WriteLine("Value pattern not supported for " + AElement.Current.Name);
return;
}
我正在传递一个带有 controltype.Edit 的 AutomationElement,当我检查这个元素时,我收到了这条信息:
ControlType.Edit
ValuePatternIdentifiers.Pattern
LegacyIAccessiblePatternIdentifiers.Pattern
A first chance exception of type 'System.InvalidOperationException' occurred in UIAComWrapper.dll
Value pattern not supported
有谁知道为什么它说 valuepattern 不受支持而 ValuePatternIdentifiers.Pattern 在 GetSupportedPatterns() 中列出?