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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:59:17+00:00 2026-05-26T00:59:17+00:00

I have a Pivot on MainPage.xaml ; how can I call this from another

  • 0

I have a Pivot on MainPage.xaml; how can I call this from another class?

MainPage.mypivot.Items.Add(p);


Error 2 An object reference is required for the non-static field, method, 
or property '...MainPage.mypivot'   H:\Users\Lacroix\documents\...
  • 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-26T00:59:17+00:00Added an answer on May 26, 2026 at 12:59 am

    You can’t do that exactly because of the reason the compiler tells you. MainPage is not a static class, when you view the page an instance of the class is being displayed, so you need to manipulate that instance. What you can do is pass a reference to the MainPage class to the other class. Then have MainPage contain an instance of the other class.

    In MainPage.xaml.cs

    public partial class MainPage : PhoneApplicationPage
    {
      private MyClass _myClass;
    
      MainPage()
      {
        _myClass = new MyClass( this );
    
      }
    }
    

    Now, MyClass will have access to the Pivot (and all other elements of MainPage).

    If whatever logic the other class uses to add items to the Pivot is not available when displaying MainPage, i.e. you need to add items when displaying some other page, you’ll need to create a static list (say PivotItemsList) in the App class. Have the other class add items to this list instead of directly to the Pivot. You can then access this within the MainPage constructor as App.PivotItemsList and add the items to the Pivot.

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

Sidebar

Related Questions

I have this great function that parses a field into a pivot table consisting
As seen here: http://www.tsqltutorials.com/pivot.php What if I don't have a column I can perform
In my MainPage.xaml , I created a Pivot Control: <controls:Pivot Title=Powder God Name=PivotControl> .
I have a Pivot layout with three items. One holds news for today, the
I have a Pivot control which I am using as following within the XAML.
I have the following tables items similars items_similars = pivot table items->similars has a
I have in my Xaml a pivot control : <controls:Pivot ItemsSource={Binding ObjectList}> <controls:Pivot.HeaderTemplate> <DataTemplate>
I have a screen with pivot functionality, and I'd very much like just one
i have 3 listboxes in a pivot page. Normaly when i write something like:
I have a workbook with 20 different pivot tables. Is there any easy way

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.