我想设置一个测试,看看我的代码是否在没有互联网访问时正常工作.有没有办法暂时关闭互联网访问测试?
我试着环顾四周,但我找不到它.
我有一种通过绑定加载图像供以后使用的方法。
当我按如下方式设置它时,它可以工作:
public static ImageSource LoadImage()
{
return new BitmapImage(
new Uri("C:/User/Name/Documents/Visual Studio 2015/Projects/Project/bin/debug/subfolder/sprite.png", UriKind.Absolute));
}
Run Code Online (Sandbox Code Playgroud)
但是,当我切换到简单地使用时:
public static ImageSource LoadImage()
{
return new BitmapImage(
new Uri("/subfolder/sprite.png", UriKind.Relative));
}
Run Code Online (Sandbox Code Playgroud)
XAML 不显示图像。我看了看Environment.CurrentDirectory它又回来了"C:/User/Name/Documents/Visual Studio 2015/Projects/Project/bin/debug/"
我已经用谷歌搜索了一个解决方案,但似乎什么也看不到。