我正在尝试在全景视图的代码中创建一个本地化的应用程序栏。这是我的代码:
// 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'是'type',但用作'变量'。知道为什么吗?非常感谢!
费;
答案 0 :(得分:2)
您的专有名称与其类型相同。重命名它。所以:
ApplicationBar ApplicationBar
{
get;
set;
}
到
ApplicationBar MyApplicationBar
{
get;
set;
}
和
ApplicationBar = new ApplicationBar();
到
this.MyApplicationBar = new ApplicationBar();
以及对this.MyApplicationBar