StackPanel.GetInsertionIndexes(Point, Int32, Int32) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Returns the index values of the items that the specified point is between.
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)
Parameters
- position
- Point
The point for which to get insertion indexes.
- first
-
Int32
int
The index of the item before the specified point.
- second
-
Int32
int
The index of the item after the specified point.
Implements
Windows requirements
Device family |
Windows 10 Anniversary Edition (introduced in 10.0.14393.0)
|
API contract |
Windows.Foundation.UniversalApiContract (introduced in v3.0)
|
Remarks
Call this method when handling a DragOver event to return the indices of the two items between which the DragOver is happening and where a potential drop and insertion would happen.
Version compatibility
The GetInsertionIndexes method is not available prior to Windows 10, version 1607. If your app’s 'minimum platform version' setting in Microsoft Visual Studio is less than the 'introduced version' shown in the Requirements block later in this page, you must design and test your app to account for this. For more info, see Version adaptive code.
To avoid exceptions when your app runs on previous versions of Windows 10, do not call this method without first performing a runtime check. This example shows how to use the ApiInformation class to check for the presence of this method before you use it.
<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);
}
}
}