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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:16:57+00:00 2026-05-25T11:16:57+00:00

I am building a Silverlight app which comprises a TreeView of menu options in

  • 0

I am building a Silverlight app which comprises a TreeView of menu options in a lefthand column and a ContentView in a righthand column. The idea is that the SelectedItemChanged event of the TreeView will change the view in the content area.

What is the ‘purest MVVM’ way of achieving this?

My idea is to have a TreeMenuView and TreeMenuViewModel for managing the menu events, but after that I’m a bit lost. I could use an EventAggregator to send a message from the TreeMenuViewModel to a `ContentViewModel’ that would then set its current ContentView based on the message args- but surely that breaks MVVM, in the sense that a ViewModel shouldn’t know about UI constructs like a View?

Am I missing something simple here?

How does a ViewModel layer drive the View selection?

  • 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-25T11:16:57+00:00Added an answer on May 25, 2026 at 11:16 am

    I would create a ShellViewModel which had:

    • ObservableCollection<ViewModelBase> AvailablePages
    • int SelectedPageIndex
    • ViewModelBase CurrentPage, which returns AvailablePages[SelectedPageIndex]

    Your ShellView can be anything you want. If you want to display your AvailablePages in a TreeView, then go ahead. Just remember to bind SelectedIndex to `SelectedPageIndex

    In your case, I would create a DockPanel with a TreeView on the Left bound to AvailablePages, and a ContentControl on the right with ContentControl.Content bound to CurrentPage

    Edit

    Here’s an example

    <DockPanel>
        <TreeView DockPanel.Dock="Right"
                  ItemsSource="{Binding AvailablePages}"
                  SelectedItem="{Binding SelectedPageIndex}">
        ...
        </TreeView>
    
        <ContentControl Content="{Binding CurrentPage}" />
    </DockPanel>
    

    Then use DataTemplates to define how the ContentControl containing CurrentPage will look

    <Window.Resources>
        <DataTemplate DataType="{x:Type local:HomePageViewModel}" />
             <local:HomePageView />
        </DataTemplate>
        <DataTemplate DataType="{x:Type local:CustomerViewModel}" />
             <local:CustomerView />
        </DataTemplate>
    </Window.Resources>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a silverlight app in Blend that will contain a treeview and treeviewitems.
Let me try to explain my challenge. I'm building a Silverlight app which will
I am building a web app in Silverlight which allows users to view and
I'm building a wp7 Silverlight app. I need a list that is able to
I'm building an app that generates a grid of HubTile objects from the Silverlight
This morning I tried running a Silverlight 5 App that we have been building
Building a Silverlight 5 app that runs in the browser but getting some nagging
We're building an application that is a Silverlight client application, but we've created an
I'm building a Silverlight 4 UserControl in Blend which has three VisualStates. I would
I am evaluating options for a desktop app which needs to support both Windows

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.