Parent&VisualOperations

Where's VisualOperations in november I want to know Parent of ListViewItem but ListViewItem.Parent is null.

Thanks.


Answer this question

Parent&VisualOperations

  • Pirox

    OK,I found VisualTreeHelper-it works as before,but what about LogicalTreeHelper
    What is the difference LogicalTreeHelper.GetParent(ListViewItem)==null and VisualTreeHelper.GetParent(ListViewItem) is not.Why
    By the way it could be useful to have shortcut for Parent in such elements as ListViewItem which dosen't exists by itself.

    Thanks.

  • Natalie Casey

    WPF has 2 trees of elements to deal with.  There is the logical tree with things like controls that can render with styling and templates.  There is the visual tree which is the actual tree of things to render. Your List is most likely in a template or such where there is no logical enclosing element, but has a visual parent because it is being rendered as the expansion of the template.

  • Pintag

    Concept of Visual tree in WPF is similar to a shadow tree in SVG-sXBL:)

    - sk

  • NewHacker

    So,you say that elements coming not from template will be included in logical tree but that visuals+visuals contained in templates form visual tree
    It could be helpful to have formal definition of this trees...

    Thanks.

  • Tyson882

    That's exactly right and it is a key concept of the WPF architecture. There is a very good set of documentation on the Visual vs. Logical tree available here in the SDK.

    HTH,
    Drew

  • Parent&VisualOperations