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

常州做网站需要多少钱海尔建设网站的内容

常州做网站需要多少钱,海尔建设网站的内容,什么网站做的好看又便宜,杭州两网建设WPF COMMAND在Windows Presentation Foundation#xff08;WPF#xff09;框架中是一个设计模式#xff0c;主要用于实现用户界面#xff08;UI#xff09;元素和业务逻辑之间的松耦合交互。具体来说#xff0c;它是MVVM#xff08;Model-View-ViewModel#xff09;架构…WPF COMMAND在Windows Presentation FoundationWPF框架中是一个设计模式主要用于实现用户界面UI元素和业务逻辑之间的松耦合交互。具体来说它是MVVMModel-View-ViewModel架构中的重要组成部分。 在WPF中Command是一种行为允许UI控件如按钮的Command属性绑定到一个命令对象而不是直接绑定到一个方法调用。当用户触发UI事件时例如点击按钮相应的命令会被执行并且该命令可以关联到任何实现了 ICommand 接口的对象这个对象定义了何时命令可执行以及执行命令时应进行的操作。 通过这种方式开发者可以在ViewModel层中定义命令并处理业务逻辑然后在View层中仅声明要绑定的命令从而极大地增强了代码的可维护性和可测试性。 在WPF应用中可以通过数据绑定将ICommand实例与UI控件如Button的Command属性关联起来控件的Command属性绑定的主要是方法这样在用户与UI交互时就能够自动调用对应的命令执行逻辑而无需直接在控件的事件处理器中写入复杂的业务代码。 不管是ICommand还是INotifyPropertyChanged 都必须首先将ViewMode的实例设置为控件或整个界面的 DataContext如this.DataContext new MainViewModel();DataContext是UI层与数据逻辑层的桥梁。 ICommand 接口中定义了两个方法和一个属性 Execute 方法当命令被调用时执行的方法通常在这里编写处理实际业务逻辑的代码。 void Execute(object parameter); CanExecute 方法判断命令当前是否可以被执行。这个方法返回一个布尔值视图会根据这个值决定是否使能关联的UI控件。 bool CanExecute(object parameter); CanExecuteChanged 事件当命令的可执行状态改变时触发此事件视图接收到此事件后会重新检查并更新相关UI控件的状态。 event EventHandler CanExecuteChanged; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows;namespace WpfApplication1 {public class MainViewModel{public MainViewModel(){ShowMyCommand new MyCommand(show);}public MyCommand ShowMyCommand{set;get;}public void show(){MessageBox.Show(按钮2被点击了);}} }using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes;namespace WpfApplication1 {/// summary/// MainWindow.xaml 的交互逻辑/// /summarypublic partial class MainWindow : Window{public MainWindow(){InitializeComponent();this.DataContext new MainViewModel();//MainViewModel作为数据源为MainWindow提供上下文}private void Button_Click(object sender, RoutedEventArgs e){MessageBox.Show(按钮被点击了);}} }using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Input;namespace WpfApplication1 {public class MyCommand : ICommand{public Action ExecuteAction;public MyCommand(Action act){ExecuteAction act;}public event EventHandler CanExecuteChanged;public bool CanExecute(object parameter){return true;}public void Execute(object parameter){ExecuteAction();}} }Window x:ClassWpfApplication1.MainWindowxmlnshttp://schemas.microsoft.com/winfx/2006/xaml/presentationxmlns:xhttp://schemas.microsoft.com/winfx/2006/xamlxmlns:dhttp://schemas.microsoft.com/expression/blend/2008xmlns:mchttp://schemas.openxmlformats.org/markup-compatibility/2006xmlns:localclr-namespace:WpfApplication1mc:IgnorabledTitleMainWindow Height350 Width525GridStackPanelButton Content按钮 ClickButton_Click/ !--以事件方式触发--Button Content按钮2 NamebtnCommand Command{Binding ShowMyCommand}/!--已绑定方式实现--/StackPanel/Grid /Window
http://www.zqtcl.cn/news/657551/

相关文章:

  • 如何自己开网站网络服务检测与维护
  • 古镇网站建设熊掌号专业网站开发哪里有
  • 专业做网站服务上海网站开发哪家好
  • 科普重庆网站浙江网站开发
  • 怎么搭建自己的网站后台邹城网站建设哪家好
  • 二手房在哪个网站做合同wordpress 局域网 慢
  • 全包胶衣网站wordpress 3.1
  • 怎么仿照别人网站建电商网站
  • 网站每年维护费用天津智能网站建设
  • php开发网站建设仿摄影网站
  • 动漫网站源码下载百度指数是啥
  • 建站之星演示谷歌网站建站
  • wordpress是建站工具 还是语言表格制作
  • 北京中国建设银行招聘信息网站店标logo图片免费制作
  • 网站建设分金手指专业二七文章网站是怎么做的
  • 东莞网站设计企业怎么制作手机app及网站
  • 林州做网站下载做蛋糕网站
  • 做网站改版的做实验用哪些国外网站
  • 什么是静态页面网站甜品网站建设方案
  • 做一个网站大概多少钱养生网站源码
  • 淘宝客网站建设分类校园网站开发设计报告
  • 个人网站模板 免费儿童编程培训机构
  • 运动健身型网站开发免费ddns域名注册
  • 专业pc网站建设wordpress 支持php7.1
  • 廊坊网站制作系统虚拟服务器搭建
  • 做网站的优势wordpress百度索引链接
  • 网站哪些功能是PHP做的wordpress 正文宽度
  • wordpress考试主题株洲优化公司
  • 怎么做企业网站建设方案怎样查网站有没有备案
  • 浙江短视频seo优化网站专做童装的网站