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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:32:18+00:00 2026-05-22T22:32:18+00:00

I searched this site and i found 2 Links how to load wpf usercontrol

  • 0

I searched this site and i found 2 Links
how to load wpf usercontrol in MVVM pattern

MVVM-Light: Load UserControl into Window

but still i cant find the answer to my problem and this link

MVVM-Light Locator Pattern and Reusable UserControl

i Didn’t Understood…. so here is i am stating my problem which might help others struggling like me ……

I have a MainWindow which has 2 parts one has a TreeView(a
UserControl) and the other Displays different user controls(named DisplayPanel)…. just like windows Explorer.

The Display Panel on the Right side will display different user controls on Clicking nodes of tree view.

and my TreeView is Itself a user Control.

How can i make this composite UI Work using MVVM. Also I am planning to use MVVM light Toolkit. Does this have something that can help…

An Example will be great

Thanks… 🙂

Edit

My TreeView in a UserControl I made a dependency property in the UserControl which catches the selected Item fo the tree view so that i can use this dependency property to populate the required view in the “MainView” ContentControl binding….as you advised me in the comments. Everything is till now

Problem is that i want to display data contained in the the selected item and i cannot set the DataContext of the UserControls(which will be displayed in right hand side) to the selected item as then i will not be able to use my view model for the respective usercontrol for commands and other operations

I tried to solve this too…. i used the Mediator (Messenger) in my TreeViewUserControl view model to send a Message to the Usercontrol’s(the one that i need to display) view model . Message will be passed whenever the item is selected in the tree view. and message contains the selected node. I forgot to mention i set the datacontext of the UserControl to its view model so that i could display data

But using this approach the problem is that when the I click a type of node for the first time the data is not populated but if the same type of node is clicked again its populated. What’s happening is that UserControls object is availabe when the the tree item is clicked for the first time and Mediator sends the message. So Mediator is not able to pass the message to the userControl view model…..

I totally do not have ne idea to solve this further…. is my way if displaying user control right or I should do something that else….totally confused…..

  • 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-22T22:32:18+00:00Added an answer on May 22, 2026 at 10:32 pm

    You could try defining a DataTemplate for each type in the TreeView’s ItemsSource and instead of having a specific UserControl on the right side, just bind to the TreeView’s SelectedItem. Alternatively, you could use a DataTemplateSelector.

    Edited for OP’s Edit
    Did you do this?

    • MainWindow has TreeView whose ItemsSource=Binding MainVM.Items.
    • MainWindow has ContentControl whose Content=Binding TreeView.SelectedItem.
    • Somewhere in project, have ResourceDictionary where each possible type in MainVM.Items has a DataTemplate defined?

    Which ViewModel (MainVM or ItemVM) are you trying to use and why can’t you use it?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Preface: I am sure this is incredibly simple, but I have searched this site
I've searched for this on different places but I haven't found an exhaustive answer.
Okay, so I have searched this site and found many tutorials on how to
I have searched google, but I didn't find anything. I searched this site and
I searched this site and found an FTPWebRequest example via Powershell. I put it
I already searched the site and found this: GameCenter Invitation Handler He says: As
I've searched the site for similar posts but i found just one where the
I have searched this site for an answer and found many responses to unsigned/signed
I searched the site but it seems like this exercise from the book Learn
I have searched and found a couple of solutions on this site, that didn't

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.