ScreenBase

出自 骑砍中文百科
前往: 導覽搜尋

訪問源文檔
返回目錄

你可以通過Screen組織和實例化你的 ViewModelsMovies 為了避免一些問題,請在創建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>());