Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. public RootViewModel(ViewModelBase view)
  2. {
  3. CurrentContentVM = view;
  4. }
  5.  
  6. private ViewModelBase currentContentVM;
  7. public ViewModelBase CurrentContentVM
  8. {
  9. get
  10. {
  11. return currentContentVM;
  12. }
  13. set
  14. {
  15. currentContentVM = value;
  16. RaisePropertyChanged(() => CurrentContentVM);
  17. }
  18. }
  19.  
  20. <Window.Resources>
  21. <DataTemplate DataType="{x:Type vm:AuthViewModel}">
  22. <local:AuthControl />
  23. </DataTemplate>
  24. <DataTemplate DataType="{x:Type vm:CalculateViewModel}">
  25. <view:CalculateControl />
  26. </DataTemplate>
  27. <DataTemplate DataType="{x:Type vm:CaloriesViewModel}">
  28. <view:CaloriesControl/>
  29. </DataTemplate>
  30. </Window.Resources>
  31. <Grid>
  32. <ContentControl Content="{Binding CurrentContentVM}"/>
  33. </Grid>
  34.  
  35. private string _fieldFio;
  36. RootViewModel root;
  37. public string FieldFio
  38. {
  39. get
  40. {
  41. return _fieldFio;
  42. }
  43. set
  44. {
  45. _fieldFio = value;
  46. RaisePropertyChanged(() => FieldFio);
  47. }
  48. }
  49.  
  50. public ICommand CommandLogin //Это команда на кнопке
  51. {
  52. get
  53. {
  54. return _commandLogin ?? (_commandLogin = new RelayCommand(() => {
  55. if (!string.IsNullOrEmpty(FieldFio) && FieldFio.Equals("Admin"))
  56. root = new RootViewModel(new CaloriesViewModel());
  57. else
  58. MessageBox.Show("Неверный формат входной строки");
  59. }));
  60. }
  61. }
  62.  
  63. public MainWindow()
  64. {
  65. InitializeComponent();
  66. DataContext = new ViewModels.RootViewModel(new ViewModels.AuthViewModel());
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement