当前位置: 首页 > news >正文

快速建站教程wordpress导入文件太大

快速建站教程,wordpress导入文件太大,建设网站的会计分录,摄影网站制作教程MvvmLight框架使用入门#xff08;三#xff09; 本篇是MvvmLight框架使用入门的第三篇。从本篇开始#xff0c;所有代码将通过Windows 10的Universal App来演示。我们将创建一个Universal App并应用MvvmLight框架。 首先通过VS2015创建一个名为UniversalApp的空工程#x…MvvmLight框架使用入门三   本篇是MvvmLight框架使用入门的第三篇。从本篇开始所有代码将通过Windows 10的Universal App来演示。我们将创建一个Universal App并应用MvvmLight框架。   首先通过VS2015创建一个名为UniversalApp的空工程工程类型为Universal Windows然后通过NuGet获取MvvmLight这里需要注意的是我们选择MvvmLightLib仅下载DLL文件因为MvvmLight还未对Universal App做适配并不会自动创建ViewModel以及ViewModelLocator等文件。   在创建UniversalApp完成后将上一篇创建的HelloMvvmLight工程中的ViewModel文件夹整个拷贝到UWP工程里注意修改namespace。这样MainViewModel以及ViewModelLocator文件就有了。 接着在App.xaml的Resources中添加对ViewModelLocator的引用 Application.ResourcesResourceDictionaryvm:ViewModelLocator x:KeyLocator //ResourceDictionary/Application.Resources   这里需要注意保持namespace和ViewModel的namespace一致xmlns:vmusing:UniversalApp.ViewModel   再下一步就是修改MainPage.xaml文件将xaml的内容修改如下 Page.DataContextBinding PathMain Source{StaticResource Locator}/Binding/Page.DataContextGridGrid.RowDefinitionsRowDefinition HeightAuto/RowDefinitionRowDefinition HeightAuto/RowDefinition/Grid.RowDefinitionsTextBlock Text{Binding Title}/TextBlockButton Grid.Row1 Command{Binding ChangeTitleCommand}Click Me!/Button/Grid   至此一个简单的使用了MvvmLight框架的Uinversal App就完成了。   按下CtrlF5,一个Win10风格的窗体就出现了。细心的童鞋会发现Button默认不再撑开了   当然本篇不会只有这点东西我们会进一步介绍MvvmLight框架在Universal App下的使用。   接下来我们增加第二个页面来看一下MvvmLight对页面间导航的支持。   第一步新建PageTwoViewModel类 public class PageTwoViewModel{private INavigationService _navigationService;public ICommand GoBackCommand { get; set; }public PageTwoViewModel(INavigationService navigationService){_navigationService navigationService;GoBackCommand new RelayCommand(() { _navigationService.GoBack(); });}}   INavigationService是MvvmLight为了抽象各类型的工程WPF,Silverlight,Windows Runtime不同的导航方法而设计的接口定义如下 public interface INavigationService{string CurrentPageKey { get; }void GoBack();void NavigateTo(string pageKey);void NavigateTo(string pageKey, object parameter);}   通过string字符串确认唯一页面来进行跳转和返回并可以传递object类型的参数。   ViewModelLocator类注册PageTwoViewModel以及创建INavigationService的实例并关联各Page。 public ViewModelLocator(){ServiceLocator.SetLocatorProvider(() SimpleIoc.Default);SimpleIoc.Default.RegisterMainViewModel();SimpleIoc.Default.RegisterPageTwoViewModel();var navigationService this.CreateNavigationService();SimpleIoc.Default.RegisterINavigationService(() navigationService);}private INavigationService CreateNavigationService(){var navigationService new NavigationService();navigationService.Configure(MainPage, typeof(MainPage));navigationService.Configure(PageTwo, typeof(PageTwo));return navigationService;}public MainViewModel Main{get{return ServiceLocator.Current.GetInstanceMainViewModel();}}public PageTwoViewModel PageTwo{get{return ServiceLocator.Current.GetInstancePageTwoViewModel();}}}   至于为什么只要在PageTwoViewModel的构造函数参数中带有INavigationService即可由IOC自动获取实例navigationService则超出了本文讨论的范围有兴趣的同学自行学习。   构建PageTwo.xaml页面并关联至PageTwoViewModel。 Page.DataContextBinding PathPageTwo Source{StaticResource Locator}/Binding/Page.DataContextGrid Background{ThemeResource ApplicationPageBackgroundThemeBrush}GridGrid.RowDefinitionsRowDefinition HeightAuto/RowDefinitionRowDefinition HeightAuto/RowDefinition/Grid.RowDefinitionsTextBlock TextPage Two/TextBlockButton Grid.Row1 Command{Binding GoBackCommand}Go Back/Button/Grid/Grid   修改MainViewModel类增加GotoNextCommand等方法。同时我们可以看到手动获取navigationService对象的方法。 public class MainViewModel : ViewModelBase{private string title;public string Title{get { return title; }set { Set(ref title , value); }}public ICommand ChangeTitleCommand { get; set; }public ICommand GotoNextCommand { get; set; }public MainViewModel(){Title Hello World;ChangeTitleCommand new RelayCommand(ChangeTitle);GotoNextCommand new RelayCommand(GotoNext);}private void GotoNext(){var navigationService ServiceLocator.Current.GetInstanceINavigationService();navigationService.NavigateTo(PageTwo);}private void ChangeTitle(){Title Hello MvvmLight;}}   MainPage.xaml仅仅是增加了一个GotoNext的Button Button Grid.Row2 Command{Binding GotoNextCommand}Go to Next!/Button   大功告成按下CtrlF5试试吧。   使用MvvmLight框架中的INavigationService来进行页面导航虽然相对使用Frame导航稍稍增加了工作量但具有以下几点好处   不依赖具体的工程实现WPF,Sliverlight,Windows Runtime)。  View和ViewModel不直接产生依赖双方通过中介INavigationService打交道。也就是说ViewModel中不会出现Windows.UI.Xaml.Controls的namespace。  将跳转的实现代码从View转移到ViewModel使得单元测试可以脱离View完全的通过ViewModel的UT即可测试跳转的逻辑。  转载于:https://www.cnblogs.com/Jeely/p/11077818.html
http://www.zqtcl.cn/news/2025/

相关文章:

  • 网站实时推送怎么做网站开发工作程序怎么写
  • 短故事网站模板广东购物网站建设
  • 网页游戏魔域永恒连云港seo
  • 网站备案 人工审核网站开发最快的语言
  • 廊坊网站建设推广经验一个网站的建设方案
  • 天天新网站网站开发客户流程 6个阶段
  • 电子商务网站建设与维护论文开源php网站开发
  • ppt模板免费整套关键词优化步骤简短
  • 网站在哪里搜索网站多大够用
  • 网站建设的一些专业术语腾讯云wordpress搭建网站
  • 怎么搭建购物网站广州哪里比较好玩
  • 网站现状分析请简述网站开发的流程
  • 北京 网站设计 地址通州南宁建行 网站
  • 新乡做网站的营销型网站建设效果
  • 甘肃省建设厅备案在哪个网站wordpress 图片处理
  • 做有奖竞猜网站违法吗wordpress 自定义表单插件
  • 网站如何做问卷调查佛山专业做网站的公司
  • 网站数据库访问室内设计培训班多少钱
  • 四川省和城乡建设厅网站首页宝安区
  • 建立一个网站的英文网站如何建设与安全
  • 怎么在别人网站上做锚文本链接网站平台建设总结
  • 网站后台的数据库怎么做深圳网站制作平台
  • dw网站结构图怎么做企业建设网站有哪些费用
  • 学院网站建设的目的及定位北京高端网站建设图片大全
  • 海口网站建设q479185700棒营销图片大全
  • 企业网站管理系统 开源东莞公司网站建设小知识
  • 建设黑彩网站需要什么邮件格式模板
  • 帮别人做网站怎么赚钱php婚庆网站
  • 深圳市建设注册执业资格中心网站一流的网站建设案例
  • 网站租用价格商城网站建设都有哪些类型