共用方式為


FindControl 作業

 

發行︰ 2016年11月

適用於: Dynamics 365 (online)、Dynamics 365 (on-premises)、Dynamics CRM 2013、Dynamics CRM 2015、Dynamics CRM 2016

本主題說明可用以識別使用者介面 (UI) 控制項的兩種方法。

本主題內容

UI 樹狀結構型識別

位移型識別

UI 樹狀結構型識別

此方法取得完整控制項樹狀結構。 會使用任何控制項屬性,周遊到最後控制項。

以下是範例繫結格式:

<UIElement Name="UISystemandSecurityHyperlink">
<UIObject MatchCount="1">                            
              <AndCondition>
                <PropertyCondition Name="Name">CPCategoryPanel</PropertyCondition>
                <PropertyCondition Name="ControlType">Pane</PropertyCondition>
              </AndCondition>
                <UIObject>                                   
                  <AndCondition>
                    <PropertyCondition Name="Name">System and Security</PropertyCondition>
                    <PropertyCondition Name="ControlType">Hyperlink</PropertyCondition>
                  </AndCondition>                  
                </UIObject>
            </UIObject>
<UIElement>

標記說明如下:

  • <UIElement> – 這是根節點,有 Name 屬性:

    • Name – 擷取用於 DDA 的易記名稱。

    • StartFromDesktop – 指定搜尋是從桌面或目前上層。

    • ParentUIElement – 指定必須設為上層控制項的 UIElement。 如果是按鈕,就需要指定「pane」為 ParentUIElement。 手動建立繫結時,這會非常有用。

    • MatchCount – 指定符合計數。 如果有多個控制項擁有相同屬性,根據此索引識別它。

  • <UIObject> – 此節點擷取完整樹狀結構,以識別控制項:

    • <PropertyCondition Name="Name">CPCategoryPanel</PropertyCondition> - 擷取控制項搜尋的屬性條件。 這會群組在 AndCondition/OrCondition/NotCondition 中。 如果只有一個 PropertyCondition,它應在根節點中,而且沒有任何群組。Name 代表控制項屬性的名稱。

    • AndConditionOrConditionNotCondition – 群組屬性條件的條件。

    • <AndCondition Id="SearchCondition"> – 擷取屬性條件,用來識別控制項。Id 代表條件清單 ID。 當之後提供群組時,可以使用多個 AndCondition

    • <OrCondition Id="SearchCondition"> – 擷取屬性條件,用來識別控制項。Id 代表條件清單 ID。 當之後提供群組時,可以使用多個 OrCondition

    • <NotCondition Id="SearchCondition"> – 擷取屬性條件,用來識別控制項。Id 代表條件清單 ID。 當之後提供群組時,可以使用多個 NotCondition

    • AndConditionNotConditionOrCondition – 可以巢狀,但是必須正確群組它們。 頂端 XML 繫結只應具有一個條件,而且可以內部群組它們。

位移型識別

這種方式很容易使用,也會建置繫結。

注意

此方式不適用於控制項樹狀結構位置繼續變更時,因為它使用 UI 樹狀結構中的位置數字來識別控制項。 如果 UI 樹狀結構位置動態變更,此方式無法使用。

MatchCount 屬性做為位移等級。 必要時可提供條件。

以下顯示範例繫結格式。

<UIElement name="textBoxTabPage1">
          <UIObject MatchCount="2">            
            <UIObject  MatchCount="1">             
              <UIObject   MatchCount="2">                
              </UIObject>
            </UIObject>
          </UIObject>
        </UIElement>

另請參閱

UIADDA
使用資料驅動型配接器 (DDA)

Unified Service Desk 2.0

© 2017 Microsoft. 著作權所有,並保留一切權利。 著作權