我的 xaml 中有类似的内容:
<Grid>
<Image Name="image" Source="../../Images/DefaultImage.png" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"></Image>
</Grid>
如何获取(使用我的代码隐藏 C# 代码)图像源的绝对路径?
最佳答案
每次都对我有用的方法就是这条简单的线
(YourImage.Source as BitmapImage).UriSource
此外,您可以根据需要处理返回的 UriSource 的 AbsolutePath 或 AbsoluteUri。
关于wpf - 从 WPF 中的图像获取绝对文件路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2631604/