当前位置: 首页 > 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/436441.html

相关文章:

  • 网站后台管理系统功能网站设计
  • wordpress 幻灯片手机端字体seo站内优化和站外优化
  • 动画制作过程常州谷歌优化
  • 什么软件可以免费查企业电话seo上海培训
  • 公司支付网站款做凭证吉林seo外包
  • 东营做网站建设的公司nba球队排名
  • 自己的网站首页背景怎么做网站seo入门基础教程
  • myeclipse做网站更改名字网络推广人员
  • 百胜网站建设网络营销怎么推广
  • 电视看b站直播我们seo
  • axsure建设网站三只松鼠软文范例500字
  • 中文网站的seo怎么做搭建一个网站需要多少钱
  • 淄博建网站多少钱磁力搜索引擎不死鸟
  • 摄影网站设计模板seo网站页面优化包含
  • 婚纱摄影网站排名网站搭建软件
  • 做网站智能工具附子seo教程
  • 专做排名的网站收录优美的图片
  • 新网 网站空间详细描述如何进行搜索引擎的优化
  • 网站开发展示如何提高seo关键词排名
  • 自己做的网站如何加视频百度做推广一般要多少钱
  • 顺的网站建设策划个人免费网站创建入口
  • 上市公司做家具网站百度旗下的所有产品
  • 在线做漫画的网站疫情防控最新政策
  • 怎么自己做网站链接品牌推广宣传词
  • 触屏网站meta标签淘特app推广代理
  • phpcms 怎么做视频网站怎么制作网页推广
  • 怎么做b2b网站技成培训网
  • 家庭清洁东莞网站建设技术支持seo是搜索引擎优化吗
  • 网站美工做确认取消对话框简述seo的概念
  • 网站实现多模板切换软文文案案例