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

  • Home
  • SEARCH
  • 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 4534090
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T14:14:15+00:00 2026-05-21T14:14:15+00:00

I have a Shell.xaml file which contains two other UserControls. On the left is

  • 0

I have a Shell.xaml file which contains two other UserControls. On the left is my TreeView and on the right is a detail screen.

I want the detailscreen to be switchable based on a selected TreeViewItem. I know this can be achieved by using DataTemplates, because I’ve done it with simple button clicks and using the <ContentControl Content="{Binding CurrentDetailViewModel}"> tag to accomplish this, but I have no idea how to accomplish this based on a selected TreeViewItem. I also have a separate ViewModel class for my UserControl which holds my TreeView and a separate for each detail screen.

I’ve been using Josh Smith’s tutorial on TreeViews: http://www.codeproject.com/KB/WPF/TreeViewWithViewModel.aspx

So I also do use the TreeViewItemViewModel.cs class of his.

Could someone shed some light onto this?

Thanks,

Grant

  • 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-21T14:14:15+00:00Added an answer on May 21, 2026 at 2:14 pm

    If both the treeview and the details are displaying the same object (i.e the ItemsSource of the treeview contains the objects that you want to data template in the custom control) then you should be able to set a property on an underlying ViewModel that both controls share and have the custom control display something relevant with data templates.

    for example, in the ViewModel:

    object TreeViewSelectedItem
    {
        get{ return _treeViewSelectedItem;}
        set {_treeViewSelectedItem = value; NotifyPropertyChanged("TreeViewSelectedItem");}
    }
    

    Treeview xaml

    <TreeView ... SelectedItem={Binding TreeViewSelectedItem Mode=OneWayToSource}".../>
    

    custom control xaml

    <UserControl>
        <Control.Resources>
            <DataTemplate DataType="{x:Type Plane}">
            ....
            </DataTemplate> 
            <DataTemplate DataType="{x:Type Train}">
            ....
            </DataTemplate>
            <DataTemplate DataType="{x:Type Automobile}">
            ....
            </DataTemplate>
        </Control.Resources>
    
        <ContentControl Content={Binding TreeViewSelectedItem}"/>
    </Usercontrol>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a shell script file (run.sh) that contains the following: #!/bin/bash %JAVA_HOME%/bin/java -jar
I have a Resources.xaml file that contains a Storyboard targeted at a control named
I have a shell script which copies a few files to the current directory,
I have a shell script with a lot of echo statements. I want to
I have a shell script, which is run under a opensuse linux, that starts
I have a shell script which outputs all of the .js and .html files
I have a TabControl region in Shell.xaml: <TabControl Name=TabRegionControl prism:RegionManager.RegionName=TabRegion /> The user can
I have four Silverlight 4 apps, for which I'm trying to build a shell
Hi I user WPF/Calibur Micro/MEF. I I try have more active screen in shell.
Have a shell script that reads the files in a particular directory. #!/bin/bash for

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.