ScreenBase
访问源文档
返回目录
你可以通过Screen组织和实例化你的 ViewModels 和 Movies。
为了避免一些问题,请在创建Screen时使用以下模板:
public class MyExampleScreen : ScreenBase { private MyExampleVM _dataSource; private GauntletLayer _gauntletLayer; private GauntletMovie _movie; protected override void OnInitialize() { base.OnInitialize(); _dataSource = new MyExampleVM(); _gauntletLayer = new GauntletLayer(100) { IsFocusLayer = true }; AddLayer(_gauntletLayer); _gauntletLayer.InputRestrictions.SetInputRestrictions(); _movie = _gauntletLayer.LoadMovie("MyExampleMovie", _dataSource); } protected override void OnActivate() { base.OnActivate(); ScreenManager.TrySetFocus(_gauntletLayer); } protected override void OnDeactivate() { base.OnDeactivate(); _gauntletLayer.IsFocusLayer = false; ScreenManager.TryLoseFocus(_gauntletLayer); } protected override void OnFinalize() { base.OnFinalize(); RemoveLayer(_gauntletLayer); _dataSource = null; _gauntletLayer = null; } }
压入你的 Screen
如果要将你的 Screen 压入 Screen 栈,你可以使用如下代码:
ScreenManager.PushScreen(ViewCreatorManager.CreateScreenView<MyExampleScreen>());