C# ApplicationBar是一种类型,但在全景视图中用作变量
我试图在panorama视图的代码隐藏中创建一个本地化的应用程序栏。这是我的密码: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
// 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();