0

我正在尝试在全景视图的代码中创建一个本地化的应用程序栏。这是我的代码:

// 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;
            ApplicationBar.Buttons.Add(homeButton);
            homeButton.Click += new EventHandler(HomeButton_Click);

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

但是,它不会将我的 ApplicationBar 识别为属性。错误说:“Microsoft.Phone.Shell.ApplicationBar”是一种“类型”,但用作“变量”。知道为什么吗?非常感谢!

4

1 回答 1

2

你的礼节与它所拥有的类型同名。重命名它。所以:

ApplicationBar ApplicationBar
{
  get;
  set;
}

ApplicationBar MyApplicationBar
{
  get;
  set;
}

ApplicationBar = new ApplicationBar();

this.MyApplicationBar = new ApplicationBar();

以及任何其他提及的适当性this.MyApplicationBar

于 2012-04-10T06:35:14.097 回答