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 に答える