Answered ListView ItemClick

  • Saturday, April 21, 2012 8:24 PM
     
      Has Code

    I have ListView like this

     <ListView
                    AutomationProperties.AutomationId="ItemListView"
                    AutomationProperties.Name="Grouped Items"
                    ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}"
                    ItemTemplate="{StaticResource SmallItemTemplate}"
                    ItemContainerStyle="{StaticResource SmallTileStyle}"
                    SelectionMode="None"
                    IsItemClickEnabled="True"
                    ItemClick="ItemView_ItemClick"

    You can see that I use collection for binding elements. And DataTemplate for their layout

    On Item click I want to have position and size of Item that clicked,

    I mean here 

    private void ItemView_ItemClick(object sender, ItemClickEventArgs e)
            {

    I want to have ability to achieve UIElement that lives inside ListView, that elment that was touched.

    I know how to achieve position of UIElement, but I cant find the way how to find this element in ItemClick method

    Thanks for any help.


All Replies

  • Monday, April 23, 2012 2:08 AM
    Moderator
     
     Answered Has Code

    Hi WishMaterTS,

    You can user ItemContainerGenerator to retrieve the container from the item.

    listview.ItemContainerGenerator.ContainerFromItem(e.ClickedItem);

    Best regards,

    Min Zhu [MSFT]
    MSDN Community Support | Feedback to us

  • Monday, April 23, 2012 4:32 PM
     
     
    this is helpful thank you.