public async Task Navigate(Type targetPage, IViewModel bindingContext) { IViewPage page = (IViewPage)Activator.CreateInstance(targetPage); page.ViewModel = bindingContext; await Application.Current.MainPage.Navigation.PushAsync((Page)page, true); }
/// <summary> /// 加载内容 /// </summary> /// <param name="uri"></param> /// <returns></returns> protected virtual IViewPage LoadContent(Link link) { IModule vPageModule = this.Module.ModuleFramework.GetModule(link.ModuleName); string vPageAssemblyName = this.CheckAndTrimEndExtension(vPageModule.MainAssemblyName, ".dll"); Uri vPageUri = new Uri(string.Format("/{0};Component/Pages/{1}", vPageAssemblyName, link.ViewPageLocation), System.UriKind.Relative); IViewPage vPage = Application.LoadComponent(vPageUri) as IViewPage; vPage.Module = this.Module; return(vPage); }
private void ViewPageBox_ViewPageChanged(ViewPageBox vPageBox, Link nLink, IViewPage vPage) { MainViewModuleViewModel mvmvm = this.DataContext as MainViewModuleViewModel; foreach (LinkGroupViewModel lgvm in mvmvm.LinkGroupViewModels) { LinkViewModel selectLinkViewModel = lgvm.LinkViewModels.FirstOrDefault(lvm => lvm.ModuleName == nLink.ModuleName && lvm.ViewPageLocation == nLink.ViewPageLocation); if (selectLinkViewModel != null) { this.SelectedLink = selectLinkViewModel; break; } } }
private void SetContent(Link nLink, IViewPage vPageModule) { vPageModule.ViewPageBox = this; if (this.OnViewPageChanging != null) { this.OnViewPageChanging(this, vPageModule); } this.Content = vPageModule; if (this.OnViewPageChanged != null) { this.OnViewPageChanged(this, nLink, vPageModule); } SetValue(IsViewPageLoadingPropertyKey, false); }
public void QueuePageToCompile(IViewPage pageToCompile) { waiter.Reset(); compilePages.Enqueue(pageToCompile); }
public void QueuePageToCompile(IViewPage pageToCompile) { compilePages.Enqueue(pageToCompile); }
public void QueuePageToCompile(IViewPage pageToCompile) { compilePages.Enqueue(pageToCompile); }
// -------------------------------------------------------------------------------------------------------------------- /// <summary> /// Allows setting the 'Page' property using chained calls. /// </summary> public static T SetPage <T>(this T component, IViewPage page) where T : IWebViewComponent { component.Page = page; return((T)component); }
/// <summary> /// 当显示器里面link发生变化的时候执行 /// </summary> /// <param name="oldLink"></param> /// <param name="newLink"></param> private void OnSourceChanged(Link oldLink, Link newLink) { if (newLink != null && newLink == oldLink) { return; } //启动加载界面 SetValue(IsViewPageLoadingPropertyKey, true); //关闭前面没有结束的线程 if (this._cancellationTokenSource != null) { this._cancellationTokenSource.Cancel(); this._cancellationTokenSource = null; } IViewPage newViewPage = null; if (newLink != null) { if (!this._viewModuleCache.TryGetValue(newLink, out newViewPage)) { this._cancellationTokenSource = new CancellationTokenSource(); this.ContentLoader.Module = this.ModuleFramework.GetModule(newLink.ModuleName);//设置加载当前所用的模块 TaskScheduler scheduler = TaskScheduler.FromCurrentSynchronizationContext(); Task <IViewPage> task = this.ContentLoader.LoadContentAsync(newLink, this._cancellationTokenSource.Token); task.ContinueWith(t => { try { if (t.IsCanceled || this._cancellationTokenSource.IsCancellationRequested) { Debug.WriteLine("Cancelled navigation to '{0}'", newLink); if (this._linkStack.Peek() == newLink && this.DisplayLink != this._linkStack.Peek()) { this._linkStack.Pop(); } } else if (!t.IsFaulted && t.IsCompleted) { IViewPage viewModule = t.Result as IViewPage; if (viewModule.Parameters == null) { viewModule.Parameters = new Dictionary <string, object>(); } if (newLink.Parameters != null && newLink.Parameters.Count > 0) { foreach (string keyName in newLink.Parameters.Keys) { viewModule.Parameters.Add(keyName, newLink.Parameters[keyName]); } newLink.Parameters.Clear(); } if (viewModule.Cached) { this._viewModuleCache[newLink] = viewModule; } if (this._linkStacked && viewModule.Stacked) { this._linkStack.Push(newLink); } SetContent(newLink, viewModule); if (this.OnViewFailure != null) { this.OnViewFailure(this, newLink, oldLink); } } } catch (Exception ex) { if (this.OnViewFailure != null) { this.OnViewFailure(this, newLink, oldLink); } } finally { this._cancellationTokenSource.Dispose(); this._cancellationTokenSource = null; } }, scheduler); } else { SetContent(newLink, newViewPage); } } }
public IViewPage Push(IViewPage view) { Views.Push(view); return(view); }