Muh*_*tar 37 c# wpf imagesource
我需要动态设置图像源,请注意我的图像位于网络上的某个位置,这是我的代码
BitmapImage logo = new BitmapImage();
logo.BeginInit();
logo.UriSource = new Uri(@"pack://application:,,,\\myserver\\folder1\\Customer Data\\sample.png");
logo.EndInit(); // Getting the exception here
ImageViewer1.Source = logo;
Run Code Online (Sandbox Code Playgroud)
例外:
无法识别URI前缀
Man*_*ana 65
上述解决方案均不适合我.但这样做:
myImage.Source = new BitmapImage(new Uri(@"/Images/foo.png", UriKind.Relative));
Run Code Online (Sandbox Code Playgroud)
tim*_*tos 63
你只需要一行:
ImageViewer1.Source = new BitmapImage(new Uri(@"\myserver\folder1\Customer Data\sample.png"));
Run Code Online (Sandbox Code Playgroud)
您在此处使用的包语法是针对在应用程序中包含为资源的图像,而不是文件系统中的松散文件.
您只想将实际路径传递给UriSource:
logo.UriSource = new Uri(@"\\myserver\folder1\Customer Data\sample.png");
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
144438 次 |
最近记录: |