using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Windows.Forms; namespace Image_Upload { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); ImageViewer1.Source = new BitmapImage(new Uri("creek.jpg", UriKind.Relative)); } private void Browse_ButtonClick(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; if(dlg.ShowDialog() == DialogResult.OK) { string selectedFileName = dlg.FileName; FileNameLabel.Content = selectedFileName; BitmapImage bitmap = new BitmapImage(); bitmap.BeginInit(); bitmap.UriSource = new Uri(selectedFileName); bitmap.EndInit(); ImageViewer1.Source = bitmap; } }
DialogResult
bool?
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)