2012-10-12 22 views
0

我Solution Explorer中的图像:在control.image没有设定画面与URI

enter image description here

我的代码在PopupWinHelper:

var img = new Image 
{ 
    BitmapEffect = new DropShadowBitmapEffect(), 
    Stretch = Stretch.Fill, 
    Source = new BitmapImage(new Uri("/WpfApplication1;component/images/PopupImage.png")) 
}; 

我在主窗口代码:

private void button1_Click(object sender, RoutedEventArgs e) 
{ 
    cuswin.PopupWinHelper.ShowPopUp(150,300,"asdad", new Thickness(20)); 
} 

为什么会发生此错误?

然后我用:

var img = new Image 
{ 
    BitmapEffect = new DropShadowBitmapEffect(), 
    Stretch = Stretch.Fill, 
    Source = new BitmapImage(new Uri("/images/PopupImage.png", UriKind.Relative)) 
}; 

没有错误。但图片没有显示在图像中。

+0

无法回答我的问题吗? –

回答

0
Source = new BitmapImage(new Uri("/WpfApplication1;component/images/PopupImage.png", UriKind.Relative)) 

应该工作,假设PopupImage.png是一个资源。

Regards