Take the 2-minute tour ×

I'm trying to make a localized application bar in panorama view's code behind. Here's my code:

// Helper function to build a localized ApplicationBar
        private void BuildApplicationBar()
            // Set the page's ApplicationBar to a new instance of ApplicationBar.
            ApplicationBar = new ApplicationBar();

            ApplicationBar.Mode = ApplicationBarMode.Minimized;

            // Create a new button and set the text value to the localized string from AppResources.
            ApplicationBarIconButton homeButton = new ApplicationBarIconButton(new Uri("/Images/icons_home.png", UriKind.Relative));
            homeButton.Text = AppResources.HomeIcon;
            homeButton.Click += new EventHandler(HomeButton_Click);

            ApplicationBarIconButton searchButton = new ApplicationBarIconButton(new Uri("/Images/appbar.feature.search.rest.png", UriKind.Relative));
            searchButton.Text = AppResources.SearchIcon;
            searchButton.Click += new EventHandler(SearchButton_Click);

However, it doesn't recognize my ApplicationBar as a property. The error says: 'Microsoft.Phone.Shell.ApplicationBar' is a 'type' but is used as a 'variable'. Any idea why? Thanks very much!


share|improve this question
So what exact type are you deriving from? –  Jon Skeet Apr 10 '12 at 6:30
Is it a type? If it's a propriety try renaming. If, say, Mode is a static propriety, make sure it's public. –  Shingetsu Apr 10 '12 at 6:30
Oh, nvm, I see the problem. –  Shingetsu Apr 10 '12 at 6:33
@fei-qu Btw, it would be nice if you selected answer as best or commented any new problems. Might motivate more people to answer future questions. –  Shingetsu Apr 11 '12 at 4:52

1 Answer 1

Your propriety has the same name as the type it has. Rename it. So:

ApplicationBar ApplicationBar


ApplicationBar MyApplicationBar


ApplicationBar = new ApplicationBar();


this.MyApplicationBar = new ApplicationBar();

and any other reference to the propriety to this.MyApplicationBar

share|improve this answer
Hi Shingetsu, thanks for your reply. But actually I just made a stupid mistake. I put that method in another class in that file instead of code-behind class. ;-P –  Fei Qu Apr 11 '12 at 8:02
@FeiQu technically what I said should still be applied to avoid possible conflicts compiler level. Also, choosing a "best answer" is benefitial for everyone. It gives you a better accept rate (people are more motivated to answer) and I get a few points :P –  Shingetsu Apr 11 '12 at 15:50

Your Answer


