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

保定网站维护个人网站如何做推广

保定网站维护,个人网站如何做推广,合肥响应网站案例,生意参谋指数在线转换简单的计数案例,ViewModel开启辅助线程,模拟后端运行,该方式可以扩展为项目中的后端线程数采及运算呈现,便于实时监控数据的场景。 代码如下: MyCommand using System; using System.Collections.Generic; using Sys…

简单的计数案例,ViewModel开启辅助线程,模拟后端运行,该方式可以扩展为项目中的后端线程数采及运算呈现,便于实时监控数据的场景。

代码如下:

MyCommand

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;namespace MVVMCountDemo.ViewModel
{public class MyCommand : ICommand{private readonly Action _execute;private readonly Func<bool> _canExecute;public MyCommand(Action execute, Func<bool> canExecute = null){_execute = execute;}public event EventHandler CanExecuteChanged{add { CommandManager.RequerySuggested += value; }remove { CommandManager.RequerySuggested -= value; }}public bool CanExecute(object parameter){return _canExecute == null || _canExecute();}public void Execute(object parameter){_execute();}}
}

Notify  

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;namespace MVVMCountDemo.ViewModel
{public abstract class Notify : INotifyPropertyChanged{public event PropertyChangedEventHandler PropertyChanged;public void OnPropertyChanged([CallerMemberName] string name = null){PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));}}
}

Window.xaml

<Window x:Class="MVVMCountDemo.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:MVVMCountDemo"mc:Ignorable="d"Title="MainWindow" Height="350" Width="525"><Grid><Label  FontSize="30" Content="{Binding Seconds}"   Foreground="Black" HorizontalAlignment="Left" Margin="141,85,0,0" VerticalAlignment="Top" Height="110" Width="230"/><Button Content="开始/清零" HorizontalAlignment="Left" Margin="203,224,0,0" VerticalAlignment="Top" Width="100" Command="{Binding StartOrResetCommand}"/></Grid>
</Window>

MainWindow.cs

using MVVMCountDemo.ViewModel;
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 MVVMCountDemo
{/// <summary>/// MainWindow.xaml 的交互逻辑/// </summary>public partial class MainWindow : Window{public MainWindow(){InitializeComponent();this.DataContext = new CountDemoViewModel();}}
}

CountDemoViewModel 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using System.Windows.Threading;namespace MVVMCountDemo.ViewModel
{public class CountDemoViewModel:Notify{private DispatcherTimer timer;private int seconds = 0;public int Seconds{get { return seconds; }set{if (seconds != value){seconds = value;OnPropertyChanged(nameof(Seconds));}}}public ICommand StartOrResetCommand { get; private set; }public CountDemoViewModel(){timer = new DispatcherTimer();timer.Interval = TimeSpan.FromSeconds(1);timer.Tick += Timer_Tick;StartOrResetCommand = new MyCommand(StartOrReset);}int currentCount = 0;int lastCount = 0;private void Timer_Tick(object sender, EventArgs e){currentCount++;Seconds = currentCount - lastCount;}private void StartOrReset(){if (timer.IsEnabled){timer.Stop();Seconds = 0;lastCount = currentCount;}else{timer.Start();}}}
}

http://www.dtcms.com/wzjs/579021.html

相关文章:

  • 网络营销推广公司有哪些该如何建设和优化一个网站
  • 专业的建站公司服务代加工厂都不做网站
  • 中山百度网站建设北京用网站模板建站
  • jsp网站建设作业国际品牌的ui设计公司
  • 银川网站优化网站建设中页面
  • 乐从建网站企业信息公示系统 全国
  • 网站系统分析报告临沂网站建设电话
  • 牡丹江城乡建设局网站网站建设平台源码提供
  • 织梦网站栏目不能更新1688做网站需要多少钱
  • 网站建设 无法打开asp辽宁建设工程信息网项目经理解锁
  • 上海网站关键排名俄罗斯最新新闻消息
  • 酒类营销网站互联网法律服务平台
  • 北京到安阳大巴车几个小时seo排名工具
  • 企业邮箱收费吗桂平百度seo
  • 公司理念网站中国工商银行官网
  • 上海网站建设服务多少钱网站logo设计在线生成
  • 网站开发费用如何入帐如何利用wordpress搭建一个发卡网
  • 新乐网站制作价格做交互设计的网站
  • 项目总结嘉鱼网站建设优化
  • 群辉做网站服务器pythonwordpress不显示某个标签
  • 嘉峪关网站seo广州万户网络技术有限公司招聘
  • 帝国cms门户网站模板网站验收模版
  • 怎么创一个网站赚钱做网络推广有前途吗
  • 嘉定网站设计制作优化排名江门网站推广公司
  • 培训网站完整页面甘肃兰州区号
  • apache网站开启gzip龙潭湖网站建设
  • 怎样提高网站收录网页前端做购物网站的实训报告
  • 网站积分的作用成都网上注册公司流程
  • 百度搜索网站在第一次输入搜索内容后点搜索键没有反应建站平台软件
  • 专门做推广的网站吗软文300字介绍商品