Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public RootViewModel(ViewModelBase view)
- {
- CurrentContentVM = view;
- }
- private ViewModelBase currentContentVM;
- public ViewModelBase CurrentContentVM
- {
- get
- {
- return currentContentVM;
- }
- set
- {
- currentContentVM = value;
- RaisePropertyChanged(() => CurrentContentVM);
- }
- }
- <Window.Resources>
- <DataTemplate DataType="{x:Type vm:AuthViewModel}">
- <local:AuthControl />
- </DataTemplate>
- <DataTemplate DataType="{x:Type vm:CalculateViewModel}">
- <view:CalculateControl />
- </DataTemplate>
- <DataTemplate DataType="{x:Type vm:CaloriesViewModel}">
- <view:CaloriesControl/>
- </DataTemplate>
- </Window.Resources>
- <Grid>
- <ContentControl Content="{Binding CurrentContentVM}"/>
- </Grid>
- private string _fieldFio;
- RootViewModel root;
- public string FieldFio
- {
- get
- {
- return _fieldFio;
- }
- set
- {
- _fieldFio = value;
- RaisePropertyChanged(() => FieldFio);
- }
- }
- public ICommand CommandLogin //Это команда на кнопке
- {
- get
- {
- return _commandLogin ?? (_commandLogin = new RelayCommand(() => {
- if (!string.IsNullOrEmpty(FieldFio) && FieldFio.Equals("Admin"))
- root = new RootViewModel(new CaloriesViewModel());
- else
- MessageBox.Show("Неверный формат входной строки");
- }));
- }
- }
- public MainWindow()
- {
- InitializeComponent();
- DataContext = new ViewModels.RootViewModel(new ViewModels.AuthViewModel());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement