(X) Hide this
    • Login
    • Join
      • Generate New Image
        By clicking 'Register' you accept the terms of use .

Forums

Search in:

Go

TreeView, HierarchicalDataTemplate, event handlers, MVVM

  • CCB
    CCB
    0 points
    0 posts
    Feb 8, 2013, 06:45 PM
        Report Abuse

    Hello,

    We are using a TreeView to display a directory hierarchy; the data comes as json from a server.  We have a TreeView that is working very well for an arbitrarily deep dir structure:

    <sdk:TreeView x:Name="uploaderTree" ItemsSource="{Binding Items}" >
        <sdk:TreeView.ItemTemplate>
            <sdk:HierarchicalDataTemplate ItemsSource="{Binding Children}" >
                <TextBlock Text="{Binding Name}" />
            </sdk:HierarchicalDataTemplate>
        </sdk:TreeView.ItemTemplate>
    </sdk:TreeView>
    However, we need to handle the Expanded event (or, at least, bind TwoWay to the IsExpanded property).  Also, we need to keep track of the SelectedItem in the TreeView.

    Can someone suggest a way to combine that requirement -- handle the Expanded event and SelectedItem -- with the use of the HierarchicalDataTemplate?  I have been going around in circles with ControlTemplate, ItemTemplate, DataTemplate, Style, etc...

    Thanks for any ideas...
    (I'm doing all the work in code-behind right now, which is a real mess compared to doing the work in the ViewModel and letting the databinding sort it out!)




    Reply

All Posts

  • GeorgeGelly
    GeorgeGelly
    2 points
    1 posts
    , 02:21 PM
            Report Abuse
    Hey have you found solution for your problem?Checkout this website to get some more help regarding that.
    Reply
Page  
  • 1

To reply to this thread you must Log In to your account


Thread


Tags: 
  • Asked
    231 days ago
  • Viewed
    264
  • Last Activity
    79 days ago

Related Threads


Shortcuts