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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T14:38:01+00:00 2026-05-19T14:38:01+00:00

MVVM Question for Windows Phone Suppose you want to have multiple Lists in your

  • 0

MVVM Question for Windows Phone

Suppose you want to have multiple Lists in your View Model and have say a Pivot Form with a different ListBox in each Panel. For illustration purposes lets say we have two listboxes for People and Places in a single page but on different panels. (PeopleList and PlacesList)

How do you setup your ViewModels. Is there one MainViewModel for each list? One MainViewModel with two Lists? I’d like to be able to navigate to the appropriate detail page detail page based on their selection.

Secondly, how do you bind each listbox to a different viewmodel when the form is loaded.

My confusion is that examples seem to indicate that when a form is loaded you set context to a single “static variable” and not sure how to specify a different source of each listbox.

Below is some sample code snippets… with questions ???

   DataContext = App.ViewModel ;


    public class MainViewModel : INotifyPropertyChanged
    {
        public MainViewModel()
        {
            this.Items = new ObservableCollection<ItemViewModel>();
//?? can you have more than one of these?
        }

//?? should I have Public MainViewModel2() with this.Items = new OC<IVM2>
//...

/// Creates and adds a few ItemViewModel objects into the Items collection.
        /// </summary>
        public void LoadData()
        {
            this.Items.Add(new ItemViewModel() { VAR1 = "X", VAR2 = "Y"}) ;

 

<Grid x:Name="LayoutRoot" Background="Transparent" >
          <!--Pivot Control-->
        <controls:Pivot x:Name="Pivot" Title="MyApp" DataContext="{Binding}" Loaded="Pivot_Loaded">
            <!--Pivot item one-->

...

  <!--Pivot item two-->
            <controls:PivotItem Header="people">

                <Grid>
                    <ListBox x:Name="PeopleList" Height="442" HorizontalAlignment="Left" Margin="46,68,0,0"  VerticalAlignment="Top" Width="346" ItemsSource="{Binding ItemsA}" SelectionChanged="ListBox1_SelectionChanged" />
                </Grid>

<!--Pivot item three-->
            <controls:PivotItem Header="places">

                <Grid>
                    <ListBox x:Name="PlacesList" Height="442" HorizontalAlignment="Left" Margin="46,68,0,0"  VerticalAlignment="Top" Width="346" ItemsSource="{Binding ItemsB}" SelectionChanged="ListBox2_SelectionChanged" />
            </Grid>
  • 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-19T14:38:02+00:00Added an answer on May 19, 2026 at 2:38 pm

    Answers to some of the questions:

    How many / which ViewModels?

    You should certainly have a MainViewModel here. And then that MainViewModel has

    • two properties of the types PeopleListViewModel and PlacesListViewModel, or
    • two list-properties ObservableCollection<PersonViewModel> and ObservableCollection<PlaceViewModel>. Yes, you can have as many as you like but calling them ItemsA and ItemsB isn’t the best choice.

    In the first option, create 2 views (UserControls) to hold the lists.

    In the second option, you can use an ItemsControl and a DataTemplate to show the lists.

    And in general, in MVVM try to avoid SelectedItemChanged and other events. You can databind (a section of the View) to a SelectedItem property.

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

Sidebar

Related Questions

when using mvvm pattern, when we have lists we use ObservableCollection<>. my question is
Please assist with MVVM design/understanding problem. Given that we have a Windows Phone app
In MVVM pattern I don't want to think about the view while creating the
I'm learning MVVM. I have my View filling two comboboxes from ObservableCollection properties in
I am using the MVVM model. I have a dependency property, a boolean, called
Whilst building a Windows Phone 7 app. using the MVVM pattern we've struggled to
I have A design Issue Question here i have seen MVVM light implementation and
I have a question about my Silverlight5 and MVVM pattern .. In my usercontrol
Does anybody have an idea how to change screens (views) in a MVVM View-First-Approach
I'm developing Windows Phone 7 application, and heard that MVVM pattern is useful. I

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.