Aracılığıyla paylaş


UI Otomasyon Sağlayıcı Dönüş Özellikleri

Not

Bu belgeler, ad alanında tanımlanan yönetilen UI Otomasyonu sınıflarını kullanmak isteyen .NET Framework geliştiricilerine System.Windows.Automation yöneliktir. UI Otomasyonu hakkında en son bilgiler için bkz. Windows Otomasyonu API'si: UI Otomasyonu.

Bu konu, bir UI Otomasyonu sağlayıcısının bir öğenin özelliklerini istemci uygulamalarına nasıl döndürebileceğini gösteren örnek kod içerir.

Açıkça desteklemediği herhangi bir özellik için sağlayıcının (Nothing Visual Basic'te) döndürülmesi null gerekir. Bu, UI Otomasyonu özelliğini konak penceresi sağlayıcısı gibi başka bir kaynaktan almayı denemesini sağlar.

Örnek

/// <summary>
/// Gets provider property values.
/// </summary>
/// <param name="propId">Property identifier.</param>
/// <returns>The value of the property.</returns>
object IRawElementProviderSimple.GetPropertyValue(int propId)
{
    if (propId == AutomationElementIdentifiers.NameProperty.Id)
    {
        return "Custom list control";
    }
    else if (propId == AutomationElementIdentifiers.ControlTypeProperty.Id)
    {
        return ControlType.List.Id;
    }
    else if (propId == AutomationElementIdentifiers.IsContentElementProperty.Id)
    {
        return true;
    }
    else if (propId == AutomationElementIdentifiers.IsControlElementProperty.Id)
    {
        return true;
    }
    else
    {
        return null;
    }
}
''' <summary>
''' Gets provider property values.
''' </summary>
''' <param name="propId">Property identifier.</param>
''' <returns>The value of the property.</returns>
Function GetPropertyValue(ByVal propId As Integer) As Object _
    Implements IRawElementProviderSimple.GetPropertyValue

    If propId = AutomationElementIdentifiers.NameProperty.Id Then
        Return "Custom list control"
    ElseIf propId = AutomationElementIdentifiers.ControlTypeProperty.Id Then
        Return ControlType.List.Id
    ElseIf propId = AutomationElementIdentifiers.IsContentElementProperty.Id Then
        Return True
    ElseIf propId = AutomationElementIdentifiers.IsControlElementProperty.Id Then
        Return True
    Else
        Return Nothing
    End If
End Function 'IRawElementProviderSimple.GetPropertyValue

Ayrıca bkz.