我正在开发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到相对,绝对和AbsoluteOrRelative。
appbar.questionmark.rest.png被标记为资源,并复制到目录设置为“不复制”。
你可以在开始时用单点试试这条线。 ApplicationBarIconButton helpButton = new ApplicationBarIconButton(new Uri(“..// Images // appbar.questionmark.rest.png”,UriKind.Relative));你应该看看你的PNG的属性 – BigL
对不起,但它不工作。 – VansFannel
对不起,我知道我的第一条评论不起作用,只是从你的代码中复制出来,然后很快输入,我编辑它。 – BigL