Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WCF and WF
  4. Get all items in a listView with cell template

Get all items in a listView with cell template

Scheduled Pinned Locked Moved WCF and WF
databasedockerquestionlearning
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    anu81
    wrote on last edited by
    #1

    Hi all, I have a listview control which is binded with gridview columns binded to cell template with static resource. my listview is bounded to a list of class objects as itemssource.i am trying to get all the items using the below code. GridView gridView = lvView.View as GridView; foreach (TicketExceptions item in lvView.Items) { VirtualizingStackPanel vsp = (VirtualizingStackPanel)typeof(ItemsControl).InvokeMember ("_itemsHost", BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic, null, lvView, null); double scrollHeight = vsp.ScrollOwner.ScrollableHeight; double offset = (scrollHeight * lvView.Items.IndexOf(item)) / lvView.Items.Count; // itemIndex_ is index of the item which we want to show in the middle of the view vsp.SetVerticalOffset(offset); lvView.ScrollIntoView(item); ListViewItem item1 = lvView.ItemContainerGenerator.ContainerFromIndex(lvView.Items.IndexOf(item)) as ListViewItem; // item1 returns null for few items GridViewRowPresenter rowPresenter = GetFrameworkElementByName<GridViewRowPresenter>(item1); foreach (PropertyInfo info in item.GetType().GetProperties()) { for (int col = 0; col < colcount; col++) { if (rowPresenter != null) { ContentPresenter templatedParent = VisualTreeHelper.GetChild(rowPresenter, col) as ContentPresenter; TextBlock block = (TextBlock)gridView.Columns[col].CellTemplate.FindName(info.Name, templatedParent); if (block != null) { } } } } But the ItemContainerGenerator returns null for few items. when i checked, i see that only the items which are in visible in the listview (rather than scrolling) returns object using the above method, but others return null. i am able to see all the items in the listview. How can i get the container of the items without scrolling.

    Thanks in advance.:) Regards Anuradha

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups