1、消息框:
WPF的消息框和和winform的参数不一样:
if (MessageBox.Show("内容", "标题", MessageBoxButton.YesNo,
MessageBoxImage.Information) == MessageBoxResult.Yes)
Winform里可以是DialogResult.OK,WPF可以是MessageBoxResult.Yes
2、对话框:
引用Microsoft.Win32空间,调用OpenFileDialog类打开文件框,和SaveFileDialog类打开保存对话框。
例:
OpenFileDialog sfn = new OpenFileDialog();
sfn.Title = "选择复制文件";
sfn.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); //获取默认的我的文档路径。
sfn.Filter = "png文件(.png)|*.png|bmp文件(.bmp)|*.bmp|jpg文件(.jpg)|*.jpg|gif文件(.gif)|*.gif|ico文件(.ico)|*.ico|全部文件(.*)|*.*";
sfn.FilterIndex = 1;
if (sfn.ShowDialog(this) == true)
tb_SourceFileName.Text = sfn.FileName;