TreeView and DataTemplate RRS feed

  • Question

  • Im trying to use bindings on a treeview, but i can not get the template to work..

    here is what i have done:

    <sdk:TreeView Name="tvMenu" ItemTemplate="MenuData">
       <DataTemplate x:Name="MenuData">
          <StackPanel Orientation="Horizontal" >
              <TextBlock Text="{Binding Path=MenuText}"/>

    Dim item As TreeViewItem = New TreeViewItem()
    Dim dc As MenuDomainContext = New MenuDomainContext()
    Dim res = dc.Load(dc.GetIPPlanMenu2ChildsQuery(DirectCast(lb.SelectedItem, IPPlanMenu2).MenuID), AddressOf PopulateMenu, item)

    item.Header = DirectCast(lb.SelectedItem, IPPlanMenu2).MenuText
    item.ItemsSource = res.Entities


    The items are bound and displayed, but not with the "menutext" from the metadata class, it looks like its displayed with the .toString() method.

    Wednesday, March 28, 2012 10:26 AM


  • Shouldn it be <TextBlock Text="{Binding Path=Header}"/> because you assign MenuText to the Header property of your item item.Header = DirectCast(lb.SelectedItem, IPPlanMenu2).MenuText?

    Wednesday, March 28, 2012 7:43 PM