Пример #1
0
        // public IObservable<string> NavigateToPage => _navigateToPage;

        public HtmlPageViewerControl()
        {
            this.InitializeComponent();

            _navigateToPage = new Subject <string>();

            this.WhenActivated(disposable =>
            {
                ViewModel.Content.Subscribe(x => { Webview.NavigateToString(x); })
                .DisposeWith(disposable);

                ViewModel.OnScrollToTop
                .Subscribe(_ => Webview.InvokeScriptAsync("eval", new[] { "window.scrollTo(0,0);" }))
                .DisposeWith(disposable);

                ViewModel.RenderContent.Execute(Unit.Default)
                .Subscribe(DisplayPage)
                .DisposeWith(disposable);

                Webview.Events().NavigationStarting
                .Select(a => a.args)
                .Subscribe(WebViewNavigationStarting)
                .DisposeWith(disposable);

                Webview.Events().ScriptNotify
                .Select(x => KeyboardShortcutConverter.Parse(x.Value))
                .InvokeCommand(ViewModel, x => x.KeyPressed)
                .DisposeWith(disposable);

                Webview.Events().UnsupportedUriSchemeIdentified
                .Select(a => a.args)
                .Subscribe(WebViewUnsupportedUriSchemeIdentified)
                .DisposeWith(disposable);

                Webview.Events().ContainsFullScreenElementChanged
                .Select(_ => Unit.Default)
                .Subscribe(x => WebView_OnContainsFullscreenElementChanged())
                .DisposeWith(disposable);
            });
        }