0

I need to get a property of a TreeViewItem. I am able to get the reference of the treeViewItem (named tvi), But in the visual tree which I see it has a property called DocumentCount. I need to use the value of this property in the test code. I have no idea how to do that. Any insight would be great. I am attaching a snapshot of the visual tree for a better understanding

enter image description here

7
  • That's your DocTreeNode instance. Yours. You put it there. Just cast the header: var dtn = (DocTreeNode)tvi.Header; Commented Nov 12, 2016 at 21:00
  • I am not able to cast the tvi to a DocTreeControl Type. Error says cant change a TreeViewItem to a DocTreeControl. Just to give a clear idea, DocTreeNode here is a ViewModel and this view model is used for the xaml binding for the elements
    – Reema
    Commented Nov 12, 2016 at 23:05
  • Try doing what I told you to instead. I gave you the code verbatim. Copy it, paste it. Commented Nov 12, 2016 at 23:06
  • I did that...says cant change FrameworkElement to DocTreeNode
    – Reema
    Commented Nov 12, 2016 at 23:08
  • OK, cast the data context. Find where it is, and cast it Commented Nov 12, 2016 at 23:09

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.