MainWindow.xaml.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15. using Microsoft.Win32;
  16. using vCloud.TestClientUi.ViewModel;
  17. namespace vCloud.TestClientUi
  18. {
  19. /// <summary>
  20. /// MainWindow.xaml 的交互逻辑
  21. /// </summary>
  22. public partial class MainWindow : Window
  23. {
  24. private MainpageViewModel _viewModel;
  25. public MainWindow()
  26. {
  27. InitializeComponent();
  28. _viewModel = new MainpageViewModel();
  29. DataContext = _viewModel;
  30. }
  31. private void UploadFile_Click(object sender, RoutedEventArgs e)
  32. {
  33. if (_viewModel != null)
  34. {
  35. var open = new OpenFileDialog();
  36. open.Title = "请选择文件";
  37. open.Filter = "所有文件(*.*)|*.*";
  38. if (open.ShowDialog() == true)
  39. {
  40. _viewModel.FileName = open.FileName;
  41. _viewModel.UploadFileCommand.Execute(null);
  42. }
  43. }
  44. }
  45. }
  46. }