added some practice examples
This commit is contained in:
46
20241107/filedialog/MainWindow.xaml.cs
Normal file
46
20241107/filedialog/MainWindow.xaml.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user