You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
919 B
31 lines
919 B
using ReactiveUI;
|
|
|
|
namespace MyAvaloniaApp.ViewModels.Base;
|
|
|
|
/// <summary>
|
|
/// 可路由的 ViewModel 基类,实现 IRoutableViewModel 接口
|
|
/// </summary>
|
|
public abstract class RoutableViewModel : ReactiveObject, IRoutableViewModel
|
|
{
|
|
/// <summary>
|
|
/// 路由 URL 路径
|
|
/// </summary>
|
|
public string? UrlPathSegment { get; protected set; } = "未知路由";
|
|
|
|
/// <summary>
|
|
/// 宿主 Screen (IScreen 实例)
|
|
/// </summary>
|
|
public IScreen HostScreen { get; protected set; } = null!;
|
|
|
|
/// <summary>
|
|
/// 构造函数
|
|
/// </summary>
|
|
/// <param name="hostScreen">宿主 Screen</param>
|
|
/// <param name="urlPathSegment">路由 URL 路径</param>
|
|
protected RoutableViewModel(IScreen hostScreen, string? urlPathSegment = null)
|
|
{
|
|
HostScreen = hostScreen;
|
|
UrlPathSegment = urlPathSegment ?? GetType().Name.Replace("ViewModel", string.Empty);
|
|
}
|
|
}
|
|
|
|
|