<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 = "c:\\"; dlg.Filter = "Image files (*.jpg)|*.jpg|All Files (*.*)|*.*"; 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
if (dlg.ShowDialog ==System.Windows.Forms.DialogResult.OK)
if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)