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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:24:50+00:00 2026-06-05T09:24:50+00:00

I’m working with a Panorama WP7 project, and I’m having trouble binding my viewmodels

  • 0

I’m working with a Panorama WP7 project, and I’m having trouble binding my viewmodels to my view. Since my view is a Panorama, I want to have one view model for the first PanoramaItem, and a second viewmodel for the second PanoramaItem.

I can get this to work if I give x:Name properties to the PanoramaItems, but I’m trying not to do that, since MVVM discourages using x:Name properties. The alternatives I’ve tried haven’t worked though. It’s easy to set the DataContext of the entire panorama to one viewmodel, but then I don’t have the data I need for the second panorama. If I try to assign the DataContext to each PanoramaItem in that items Loaded event handler, I can get a reference to the PanoramaItem through the sender parameter in the Loaded event handler, but the compiler throws an error for the second Loaded event handler – apparently you can’t assign a Loaded event to two PanoramaItems in one Panorama. I can’t assign any event to the second PanoramaItem, for that matter.

Can anyone help?

thanks,
Andy

  • 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-06-05T09:24:52+00:00Added an answer on June 5, 2026 at 9:24 am

    OK, I figured it out. It’s possible to assign the DataContext to the PanoramaItems in the Panorama using the sender object in the Loaded event of the Panorama, as follows:

    private void HomeViewPanorama_Loaded(object sender, RoutedEventArgs e)
        {
            App.VM1 = new ViewModel1();
            App.VM2 = new ViewModel2();
    
            if (!App.VM1.IsDataLoaded)
            {
                App.VM1.LoadData();
            }
    
            if (!App.VM2.IsDataLoaded)
            {
                App.VM2.LoadData();
            }
    
            Panorama panorama = sender as Panorama;
            PanoramaItem Item1 = panorama.Items[0] as PanoramaItem;
            Item1.DataContext = App.VM1;
    
            PanoramaItem Item2= panorama.Items[1] as PanoramaItem;
            Item2.DataContext = App.VM2;
        }
    

    In this example, you have to know what your PanoramaItems are going to be, they’re not dynamic, but this method lets you refrain from x:Name’ing your controls in your XAML.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the

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.