using Microsoft.Win32; 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; namespace filedialog { /// /// Interaction logic for MainWindow.xaml /// public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void btnFire_Click(object sender, RoutedEventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Image files |*.bmp;*.jpg;*.png"; ofd.FilterIndex = 1; bool?success = ofd.ShowDialog(); if (success == true) { string path = ofd.FileName; tbInfo.Text = path; imageholder.Source = new BitmapImage(new Uri(path)); } else { //no } } } }