I have a StackPanel. The contents of the StackPanel are defined in a Data Template and they are basically another StackPanel composed of two Buttons and two Text Blocks. Now... when I touch the StackPanel I can get the element I touched through
e.TouchDevice.DirectlyOver
Where e is a TouchEventArgs variable. But I can only get the actual UIElement... I'm intrested in getting the index of the element of the StackPanel that I touched.
Anyone knows how to do that?
Thank you.
XAML:
<DataTemplate x:Key="AddBookListTemplate">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="9.9*"/>
<ColumnDefinition Width="0.1*"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical" >
<StackPanel Orientation="Horizontal">
<Button blabla>
</Button>
<Button blabla>
</Button>
</StackPanel>
<TextBlock/>
<TextBlock/>
</StackPanel>
</Grid>
</DataTemplate>
And is reused
<ScrollViewer>
<ItemsControl ItemsSource="{Binding Books}" Margin="0 10 0 0" Background="Transparent" ItemTemplate="{StaticResource AddBookListTemplate}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical" TouchEnter="StackPanel_TouchEnter"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</ScrollViewer>