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 707599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:17:46+00:00 2026-05-14T04:17:46+00:00

I am making an app in WPF in a style similar to Windows Explorer,

  • 0

I am making an app in WPF in a style similar to Windows Explorer, with a TreeView on the left and a pane on the right.

I want the contents of the right pane to change depending on the type of the selected element in the TreeView.

For example, say the top level in the Tree View contains objects of class “A”, and if you expand the “A” object you’ll see a list of “B” objects as children of the “A” object.

If the “A” object is selected, I want the right pane to show a user control for “A”, and if “B” is selected I want the right pane to show a user control for “B”.

I’ve currently got this working by:

  • setting up the TreeView with one HierarchialDataTemplate per type
  • adding all the UserControls to the right pane, but collapsed
  • implementing SelectedItemChanged on the TreeView, and setting the appropriate usercontrol to visible and the others to collapsed.

    However, I’m sure there’s a better/more elegant way to switch out the views based on the type the selection is bound to, perhaps by making more use of data binding… any ideas?

    • 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-05-14T04:17:46+00:00Added an answer on May 14, 2026 at 4:17 am

      Have you considered displaying a ContentControl as the right-side pane, and using DataTemplates to customize the contents? Then you could simply bind the right pane to the selected item of the TreeView.

      For example:

      <ContentControl Content="{Binding SelectedItem,ElementName=treeView1}">
          <ContentControl.Resources>
              <DataTemplate DataType="{x:Type my:A}">
                  <StackPanel>
                      <TextBlock Text="Displaying an A!" />
                      <TextBlock Text="{Binding Foo}" />
                  </StackPanel>
              </DataTemplate>
      
              <DataTemplate DataType="{x:Type my:B}">
                  <StackPanel>
                      <TextBlock Text="Displaying a B!" />
                      <TextBlock Text="{Binding Bar}" />
                  </StackPanel>
              </DataTemplate>
          </ContentControl.Resources>
      </ContentControl>
      
      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
        • Report

    Sidebar

    Related Questions

    I'm making a custom error dialog in my WPF app and I want to
    i'm making app that the main page include TableView but i want when i
    i m making APP which do image proceesing using java SE.i want to check
    I'm kinda new to WPF. I'm making an app using WPF (all the UI
    I am writing an app in WPF. It is getting tiresome making all my
    I'm making App in Netbeans platform in Java Swing. I want to add and
    I am making App. that includes Picture Editing, After Editing I want to save
    I searched similar questions but never found a proper answer. I am making app
    Making an app where we want to send a photo to a server along
    I making an app in Java. I want an Open With Dialog to appear

    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.