2011-03-02 66 views
0

我正在尝试使用VS2010项目的Images文件夹中的背景图像。我已阅读的文档,我尝试几种方法,包括以下,但不能得到它的工作:如何在代码隐藏中使用BitmapImage设置ImageSource路径

 ImageBrush bg2 = new ImageBrush(); 
     bg2.ImageSource = new BitmapImage(new Uri(@"/FooApplication1;component/Images/bg1.png")); 

     ImageBrush bg1 = new ImageBrush(); 
     bg1.ImageSource = new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "/FooApplication;component/Images/bg1.png")); 

任何人都知道什么是错的?

回答

0

我觉得应该URI看起来是这样的:

"pack://application:,,,/Images/bg1.png" 

你看过this article on URIs

相关问题