Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/322.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ApplicationBar是一种类型,但在全景视图中用作变量_C#_Silverlight_Windows Phone 7 - Fatal编程技术网

C# ApplicationBar是一种类型,但在全景视图中用作变量

C# ApplicationBar是一种类型,但在全景视图中用作变量,c#,silverlight,windows-phone-7,C#,Silverlight,Windows Phone 7,我试图在panorama视图的代码隐藏中创建一个本地化的应用程序栏。这是我的密码: // Helper function to build a localized ApplicationBar private void BuildApplicationBar() { // Set the page's ApplicationBar to a new instance of ApplicationBar. Applic

我试图在panorama视图的代码隐藏中创建一个本地化的应用程序栏。这是我的密码:

// 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”是“类型”,但用作“变量”。知道为什么吗?非常感谢


Fei

您的礼节与它的类型名称相同。重命名它。因此:

ApplicationBar ApplicationBar
{
  get;
  set;
}


以及任何其他对
this.MyApplicationBar

的适当性的引用,那么您从中派生出的确切类型是什么?它是一种类型吗?如果这是一个适当的尝试重命名。如果,比如说,模式是静态的,请确保它是公共的。@feiqu顺便说一句,如果您选择的答案是最佳的,或者对任何新的问题进行了评论,那就太好了。可能会激励更多的人回答未来的问题。嗨,新光,谢谢你的回答。但实际上我犯了一个愚蠢的错误。我将该方法放在该文件的另一个类中,而不是代码隐藏类中-P
ApplicationBar MyApplicationBar
{
  get;
  set;
}
ApplicationBar = new ApplicationBar();
this.MyApplicationBar = new ApplicationBar();