私はWindows Phone 7.1アプリケーションを開発しています。相対パスまたは絶対パスの混乱
私は次のフォルダ構造を持っている:
- Images (**folder**)
|
- appbar.questionmark.rest.png
- Views(**folder**)
|
- About.xaml
- MainPage.xaml
...
を私はプログラム的にアプリバーを作成しようとしています:
private void SetUpAppBar()
{
// Set the page's ApplicationBar to a new instance of ApplicationBar.
ApplicationBar = new ApplicationBar();
// Create a new button and set the text value to the localized string from AppResources.
ApplicationBarIconButton helpButton = new ApplicationBarIconButton(new Uri("..//Images//appbar.questionmark.rest.png", UriKind.Relative));
helpButton.Text = AppResources.Help;
helpButton.Click += new EventHandler(helpButton_Click);
ApplicationBar.Buttons.Add(helpButton);
// Create a new menu item with the localized string from AppResources.
ApplicationBarMenuItem appBarHelpMenuItem = new ApplicationBarMenuItem(AppResources.Help);
appBarHelpMenuItem.Click += new EventHandler(helpButton_Click);
ApplicationBar.MenuItems.Add(appBarHelpMenuItem);
}
しかし、私は見ることができませんアプリケーションバーのアイコン。私は間違って何をしていますか?
私はこれでテストを持っている:
ApplicationBarIconButton helpButton = new ApplicationBarIconButton(new Uri("..//Images//appbar.questionmark.rest.png", UriKind.Relative))
しかし、私は無効なパス例外を取得します。私はまた、UriKindをRelative、Absolute、AbsoluteOrRelativeに変更しました。をappbar.questionmark.rest.png
は「コピーしない」に設定されているリソースとしてマークされ、ディレクトリにコピーされます。
最初に1つのポイントでこの行を試すことができます。 ApplicationBarIconButton helpButton =新しいApplicationBarIconButton(新しいUri( "..// Images // appbar.questionmark.rest.png"、UriKind.Relative));そして、あなたのPNGのプロパティを見てみる必要があります – BigL
申し訳ありませんが、動作しません。 – VansFannel
申し訳ありませんが、私の最初のコメントはあなたのコードからコピーしてすぐに入力して、それを編集しただけでは機能しません。 – BigL