Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7804561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:57:18+00:00 2026-06-02T01:57:18+00:00

I have a TreeView with nodes, so when I click on one of the

  • 0

I have a TreeView with nodes, so when I click on one of the nodes I will be updating the ListBox with items bounded to an Observable Collection, which works fine. Next when I click another node in my tree view I will have to update the ListBox with different data(which is also an Obsv.Collection). Any Ideas on how to proceed with this?

<Resources>
    <DataTemplate x:Key="clipsource">
        <StackPanel>
            <Image Name="img" Width="125" Height="70" Margin="1,0" Source="{Binding Path=Path, Converter= {x:Static l:UriToThumbnailConverter.Instance}}"/>
            <TextBlock FlowDirection="LeftToRight" FontFamily="Arial" FontSize="12" Text="{Binding Path = DisplayClipName}"/>
        </StackPanel>
    </DataTemplate>
</Resources>
<Grid  Height="Auto" Grid.Column="2" VerticalAlignment="Stretch"  x:Name="RightPane_grid" Margin="2,0,0,0" KeyboardNavigation.DirectionalNavigation="None">
    <Grid.RowDefinitions>
        <RowDefinition Height="21.205"/>
        <RowDefinition  Height="*"/>
    </Grid.RowDefinitions>
    <Rectangle  Fill="#FF232323" Stroke="#FF000000" RadiusX="3" RadiusY="3" Margin="0,0,0,0" x:Name="Right_Pane_bkg" Grid.ColumnSpan="1" Grid.RowSpan="2" KeyboardNavigation.DirectionalNavigation="None"/>
    <ListBox Name="ListBox1" SelectionMode="Extended" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto" Grid.Row="0" Background="#FF3B3B3B"  Margin="2,25,2,2" ItemsSource="{Binding}" ItemTemplate="{StaticResource clipsource}">
        <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
                <WrapPanel />
            </ItemsPanelTemplate>
        </ListBox.ItemsPanel>
        <ListBox.ItemContainerStyle>
            <Style TargetType="{x:Type ListBoxItem}">
                <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}"/>
            </Style>
        </ListBox.ItemContainerStyle>
    </ListBox>
</Grid>

Code Behind:

private void Handle_Click1(object sender, MouseButtonEventArgs e) // tree view Item
{
    ListBox1.DataContext = Clips Items;
    // Clips Items is an Obs v. Collection 
}

I have a another Obs v Collection Still Items which I have to bound it to the List box to show another view

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T01:57:21+00:00Added an answer on June 2, 2026 at 1:57 am

    You can try the following:

        <TreeView Name="MyTreeView">
            <TreeView.ItemContainerStyle>
                <Style TargetType="{x:Type TreeViewItem}">
                    <Setter Property="Header" Value="{Binding Path=Name}"/>
                    <Setter Property="ItemsSource" Value="{Binding Path=SomeItems}"/>
                </Style>
            </TreeView.ItemContainerStyle>
        </TreeView>
    
        <ListBox ItemsSource="{Binding ElementName=MyTreeView, Path=SelectedItem.SomeItems}">
            <ListBox.ItemContainerStyle>
                <Style TargetType="{x:Type ListBoxItem}">
                    <Setter Property="Content" Value="{Binding Path=Name}"/>
                </Style>
            </ListBox.ItemContainerStyle>
        </ListBox>
    

    The Binding will retrieve the items displayed in the ListBox from the SelectedItem in the TreeView using the Path SomeItems. This assumes the SelectedItem is something like this:

    public class MyTreeViewItem
    {
    
        public string Name { get; private set; }
        public ObservableCollection<MyTreeViewItem> SomeItems { get; private set; }
    
        public MyTreeViewItem(string name)
        {
            if (name == null)
                throw new ArgumentNullException("name");
    
            this.SomeItems = new ObservableCollection<MyTreeViewItem>();
            this.Name = name;
        }
    
    }
    

    When you select an item in the TreeView the children are displayed in the ListBox.

    Edit:

    To populate the TreeView use the following code:

            MyTreeViewItem a = new MyTreeViewItem("A");
            a.SomeItems.Add(new MyTreeViewItem("A1"));
            a.SomeItems.Add(new MyTreeViewItem("A2"));
            a.SomeItems.Add(new MyTreeViewItem("A3"));
    
            MyTreeViewItem b = new MyTreeViewItem("B");
            b.SomeItems.Add(new MyTreeViewItem("B1"));
            b.SomeItems.Add(new MyTreeViewItem("B2"));
            b.SomeItems.Add(new MyTreeViewItem("B3"));
    
            this.MyTreeView.ItemsSource = new MyTreeViewItem[] { a, b };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a treeview (VirtualTree) which has nodes. When a user clicks on a
I have a problem with treeview nodes. When I click on some nodes, it
I have a TreeView, which contains nodes. When a user clicks on a node,
I have treeview control with one level of parent and child nodes, each node
I have a treeView with many nodes. I want that some nodes change their
I have a treeview which contains, per node, a key and text. However, there
I have a Masterpage that has Treeview. You can select some nodes there. Based
I have treeview and a context menu that is shown for every node. One
I have a TreeView with a ContextMenu with Click events. When the click event
i use such treeview http://docs.jquery.com/Plugins/Treeview/treeview , it saves perfect opened nodes when i click

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.