WPF中访问另一个Assembly中的资源
最近需要在一个程序中访问另一个assembly中的资源,最后发现其实只能访问被reference的assembly的资源。有些书上写只要像下面这样就可以了:
<Image Width="200">
<Image.Source>
<BitmapImage UriSource="ContentAssembly;component/image.png" />
</Image.Source>
</Image>
<Image Width="200">
<Image.Source>
<BitmapImage UriSource="ContentAssembly;component/image.png" />
</Image.Source>
</Image>
或者直接 <Image Width="200" Source="ContentAssembly;component/image.png" />
后来发现需要加一个/才能成功引用,也就是<Image Width="200" Source="/ContentAssembly;component/image.png" />,或者干脆直接写绝对路径 "
pack://application:,,,/ContentAssembly;component/image.png"。
浙公网安备 33010602011771号