using Avalonia.Controls; using help.Models; using help.Views; using ReactiveUI; namespace help.ViewModels { public class MainWindowViewModel : ViewModelBase { static SuharevaContext myConnection = new SuharevaContext(); static SuharevaContext myConnection1 = new SuharevaContext(); #pragma warning disable CA1822 // Mark members as static UserControl us = new Page1(); // по умолчанию в ContentControl загружается созданная Page1 public UserControl US { get => us; set => this.RaiseAndSetIfChanged(ref us, value); } Page1ViewModel page1VM = new Page1ViewModel(myConnection); // объект для работы со свойствами из Page1, а ниже для свойство для привязки: public Page1ViewModel Page1VM { get => page1VM; set => page1VM = value; } Page2ViewModel page2VM = new Page2ViewModel(myConnection1); public Page2ViewModel Page2VM { get => page2VM; set => page2VM = value; } public void toPage2() { US = new Page2(); } public void SaveNetwork() { myConnection.SaveChanges(); US = new Page2(); } public void SaveUser() { myConnection1.SaveChanges(); US = new Page1(); } #pragma warning restore CA1822 // Mark members as static } }