Tif图像文件没有加载它显示错误 [英] Tif image file does not loaded it showns error

查看:148
本文介绍了Tif图像文件没有加载它显示错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

XAML代码



XAML code

<Grid>
        <StackPanel Orientation="Horizontal" Background="LightBlue" Height="40" VerticalAlignment="Top" >
            <Label Margin="10,0,0,0" Height="23" Name="Label1">
                Current File:
            </Label>
            <Label Margin="5,0,0,0" Height="25" Name="FileNameLabel" Width="300" />
            <Button Margin="5,0,0,0" Height="23" Name="BrowseButton" Width="75" Click="BrowseButton_Click">
                Browse
            </Button>
        </StackPanel>
        <StackPanel >
            <Image Name="ImageViewer1" Height="400" Width="400" />
        </StackPanel>
    </Grid>

C# code
private void BrowseButton_Click(object sender, RoutedEventArgs e)
      {
          Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
          dlg.InitialDirectory = &quot;c:\\&quot;;
          dlg.Filter = &quot;Image files (*.jpg)|*.jpg|All Files (*.*)|*.*&quot;;
          dlg.RestoreDirectory = true;
          bool? result = dlg.ShowDialog();
          if (dlg.ShowDialog ==System.Windows.Forms.DialogResult.OK)//this lines shown error
          {
              string selectedFileName = dlg.FileName;
              FileNameLabel.Content = selectedFileName;
              BitmapImage bitmap = new BitmapImage();
              bitmap.BeginInit();
              bitmap.UriSource = new Uri(selectedFileName);
              bitmap.EndInit();
              ImageViewer1.Source = bitmap;
          }
      }

when build the solution shown this error 

operator'==' cannot be applied to operands of type 'methodgroup' and 'System.Windows.Forms.DialogResult'

please give me the solution

推荐答案

dlg.ShowDialog没有这样的属性。

if(result == System.Windows.Forms.DialogResult。好的)

更改这样的条件



将线路更改为bool? result = dlg.ShowDialog()to bool result = dlg.ShowDialog()
dlg.ShowDialog no such property exists.
if (result ==System.Windows.Forms.DialogResult.OK)
change condition like this

change the line to bool? result = dlg.ShowDialog() to bool result = dlg.ShowDialog()


是的它会:ShowDialog是一种方法。

改变这个:

Yes it will: ShowDialog is a method.
Change this:
if (dlg.ShowDialog ==System.Windows.Forms.DialogResult.OK)



对此:


To this:

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


这篇关于Tif图像文件没有加载它显示错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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