/
EugenyCh7
/
AvaloniaRoutingExample
Обзор
Документация
Войти
/
EugenyCh7
/
AvaloniaRoutingExample
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
RoutingExample/ViewModels/MainWindowViewModel.cs
32 строки
1 KB
Eugeny Chekmarev
Реализована маршрутизация
23 янв 2025, 18:13
23 янв 2025, 18:13
bfdb449
Код
Авторство
О чём код?
using ReactiveUI; using System.Reactive; namespace RoutingExample.ViewModels { public class MainWindowViewModel : ReactiveObject, IScreen { // The Router associated with this Screen. // Required by the IScreen interface. public RoutingState Router { get; } = new RoutingState(); // The command that navigates a user to first view model. public ReactiveCommand<Unit, IRoutableViewModel> GoNext { get; } // The command that navigates a user back. public ReactiveCommand<Unit, IRoutableViewModel> GoBack => Router.NavigateBack; public MainWindowViewModel() { // Manage the routing state. Use the Router.Navigate.Execute // command to navigate to different view models. // // Note, that the Navigate.Execute method accepts an instance // of a view model, this allows you to pass parameters to // your view models, or to reuse existing view models. // GoNext = ReactiveCommand.CreateFromObservable( () => Router.Navigate.Execute(new FirstViewModel(this)) ); } } }