Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Silverlight中使用图像控件(4)_Silverlight - Fatal编程技术网

在Silverlight中使用图像控件(4)

在Silverlight中使用图像控件(4),silverlight,Silverlight,我尝试使用图像控件是一种非常基本的方法,如下所示: 因此,我最终使用XAML,如下所示: <Image x:Name="imgSmall" Stretch="Fill" Source="../Img/Small/105.jpg" Margin="10,0,0,0"></Image> new Uri(App.Current.Host.Source, "../Img/Small/105.jpg"); 那么它工作得很好。我更喜欢使用更简单的语法,直接获取图像。这可能吗

我尝试使用图像控件是一种非常基本的方法,如下所示:

因此,我最终使用XAML,如下所示:

<Image x:Name="imgSmall" Stretch="Fill" Source="../Img/Small/105.jpg" Margin="10,0,0,0"></Image> 
new Uri(App.Current.Host.Source, "../Img/Small/105.jpg");
那么它工作得很好。我更喜欢使用更简单的语法,直接获取图像。这可能吗

(图像比ClientBin高一层)

无法将所有网站图像设置为build=Resource


谢谢

It id不起作用,因为图像未添加到项目中。
将图像添加到项目中,然后您可以从xaml设置源。

您必须创建一个转换器,该转换器采用相对图像路径并添加“绝对”部分。您可以将相对Uri作为绑定值或converterParameter传递

class ImageConverter : IValueConverter
{
    // method convert()
    return new BitmapImage(new Uri(App.Current.Host.Source, ((string)parameter));
    //...
}