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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:50:07+00:00 2026-05-13T09:50:07+00:00

As I knock off more and more MVVM-related issues with my current application, more

  • 0

As I knock off more and more MVVM-related issues with my current application, more just keep popping up. 🙂

The current implementation that I am trying to replace involves a StackPanel whose children are more or less dynamically generated (via looking in a configuration file). Each child is an instance of a UserControl. Before, what I did was assign a name to the StackPanel, and then in the Window_Loaded event handler, I’d simply determine the necessary number of children, instantiate one UserControl for each, and also assign the UserControl an ID so I’d know the proper source for the Buttons clicked on a particular UserControl instance; each UserControl has 3 buttons on it.

So I know I want to bind the StackPanel to a collection. This of course, is not possible, as I need to use something that derives from ItemsControl, like ListBox or ListView (or even ItemsControl itself). To keep it easy in the first iteration of MVVM-ifying, I’ll just use a ListBox.

Now the question is, should my ObservableCollection in the code-behind be a ObservableCollection? I believe this means that no matter how I skin my GUI, this ListBox will always have children that look however they do in MyUserControl’s XAML file. I’d like this to be customizable as well, but I assume this means I have to apply the MVVM pattern to the UserControl as well.

  • 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-13T09:50:08+00:00Added an answer on May 13, 2026 at 9:50 am

    If you want each of your list items to have different templates, and want to stick to an MVVM style, you’re better off not thinking in terms of UserControls.

    You can have your main view to have a ListBox bound to an observable collection of View Model instances. If you setup your data templates to map the ViewModel classes to their appropriate UserControl, you don’t need to ever explicitly load UserControls – just bind any ItemsControl to your collection of ViewModels, and let the data templates take care of constructing and mapping this to the correct UserControl for that VM.

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

Sidebar

Related Questions

I'm trying to knock together a little batch script for downloading files, that takes
I'm trying to knock the rust off my SQL skills and need some help
We're looking for a cheap-to-free off the shelf ASP.NET catalogue application, that will meet
I am looking to knock off a quickie rails app that will allow two
I have a prosperity application written in-house in PHP for collaboration (Basecamp knock off).
I need to knock up a very quick prototype/proof of concept application to demo
I've read xUnit Test Patterns. http://martinfowler.com/books.html There is 'Churchillian knock-off' expression in Martin Fowler's
ShareKit is a really nice and easy sharing solution to knock off iPhone App
I am creating a simple Knock Knock application (socket programming) where there is a
I'm trying to slowly knock out all of the intricacies of python. Basically, I'm

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.