[解决]图像控件没有加载tiff文件,请找到解决方案。 [英] [Solved] Image control does not loaded the tiff file,please find the solution.

查看:80
本文介绍了[解决]图像控件没有加载tiff文件,请找到解决方案。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

文件浏览按钮代码:



file browse button code:

private void RibbonButton_Click_1(object sender, RoutedEventArgs e)
       {
           Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
           dlg.InitialDirectory = @"c:\";
           dlg.Filter = "Image files (*.tif)|*.tif|All Files (*.*)|*.*";
           dlg.RestoreDirectory = true;
           bool? result = dlg.ShowDialog();
           if (dlg.ShowDialog == System.Windows.Forms.DialogResult.OK)
           {
               string selectedFileName = dlg.FileName;
               Label1.Content = selectedFileName;
               BitmapImage bitmap = new BitmapImage();
               bitmap.BeginInit();
               bitmap.UriSource = new Uri(selectedFileName);
               bitmap.EndInit();
               Imageviewer1.Source = bitmap;
           }

推荐答案

if (result.HasValue && result.Value)



应该这样做,而不是


should do it, instead of

if (dlg.ShowDialog == System.Windows.Forms.DialogResult.OK)


这篇关于[解决]图像控件没有加载tiff文件,请找到解决方案。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆