我试图在WPF中重新创建一个非常简单的C#项目示例,它是一个简单的图像查看器。从"Sams Teach Yourself C#"中,我已经成功打开了文件对话框,但如何将图像路径设置为WPF中的image.source控件呢?
private void SearchBtn_Click(object sender, RoutedEventArgs e)
{
Microsoft.Win32.OpenFileDialog openfile = new Microsoft.Win32.OpenFileDialog();
openfile.DefaultExt = "*.jpg";
openfile.Filter = "Image Files|*.jpg";
Nullable<bool> result = openfile.ShowDialog();
if (result == true)
{
//imagebox.Source = openfile.FileName;
}
}