如果前往的页面与当前页面相同,则不添加新的页面到页面栈中

v2.0.x
leiurayer 4 months ago
parent e5310718ab
commit 63b7fd9063

@ -11,7 +11,7 @@ public partial class VideoDetailViewModel : ViewModelBase
public const string Key = "VideoDetail";
// 保存输入字符串,避免被用户修改
private string? input = null;
private string? _input = null;
#region 页面属性申明
@ -85,6 +85,12 @@ public partial class VideoDetailViewModel : ViewModelBase
{
base.OnNavigatedTo(parameter);
if (parameter!.ContainsKey("value"))
{
_input = (string)parameter["value"];
InputText = _input;
}
}
}

@ -125,10 +125,15 @@ public partial class MainWindowViewModel : ViewModelBase
var viewModel = SetContent(viewKey);
if (viewModel == null) { return; }
// 如果前往的页面与当前页面相同,
// 则不添加新的页面到页面栈中
if (viewModel != Content)
{
_pages.Push(viewKey);
}
viewModel.OnNavigatedTo(parameter);
Content = viewModel;
_pages.Push(viewKey);
}
public void Backward(Dictionary<string, object>? parameter = null)

Loading…
Cancel
Save