Share via


StackPanel.GetInsertionIndexes(Point, Int32, Int32) 方法

定義

傳回指定點介於 的專案索引值。

public:
 virtual void GetInsertionIndexes(Point position, [Out] int & first, [Out] int & second) = GetInsertionIndexes;
void GetInsertionIndexes(Point const& position, [Out] int & first, [Out] int & second);
public void GetInsertionIndexes(Point position, out int first, out int second);
Public Sub GetInsertionIndexes (position As Point, ByRef first As Integer, ByRef second As Integer)

參數

position
Point

要取得插入索引的點。

first
Int32

int

指定點之前的專案索引。

second
Int32

int

指定點之後的專案索引。

實作

M:Microsoft.UI.Xaml.Controls.IInsertionPanel.GetInsertionIndexes(Windows.Foundation.Point,System.Int32@,System.Int32@) M:Microsoft.UI.Xaml.Controls.IInsertionPanel.GetInsertionIndexes(Windows.Foundation.Point,int@,int@)

備註

處理 DragOver 事件時呼叫這個方法,以傳回 發生 DragOver 的兩個專案索引,以及可能發生的置放和插入位置。

版本相容性

在 Windows 10 1607 版之前,無法使用 GetInsertionIndexes 方法。 如果您的 App 在 Microsoft Visual Studio 中的「最低平臺版本」設定小於此頁面稍後的 [需求] 區塊中顯示的「引進版本」,您必須設計並測試您的應用程式以考慮此設定。 如需詳細資訊,請參閱 版本調適型程序代碼

若要避免在舊版 Windows 10 上執行應用程式時發生例外狀況,請勿在沒有先執行運行時間檢查的情況下呼叫此方法。 此範例示範如何使用 ApiInformation 類別來檢查此方法是否存在,再使用它。

<StackPanel AllowDrop="True" DragOver="StackPanel_DragOver">
private void StackPanel_DragOver(object sender, DragEventArgs e)
{
    if (ApiInformation.IsMethodPresent("Windows.UI.Xaml.Controls.StackPanel", "GetInsertionIndexes"))
    {
        StackPanel stackPanel = sender as StackPanel;
        if (stackPanel != null)
        {
            int preceedingIndex;
            int subsequentIndex;
            stackPanel.GetInsertionIndexes(e.GetPosition(stackPanel), out preceedingIndex, out subsequentIndex);
        }
    }
}

適用於