using Audit.View; using GalaSoft.MvvmLight; using Models; using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Web.Services.Description; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Threading; namespace Audit.ViewModel { /// /// StuffViewModel /// public class StuffViewModel : ViewModelBase { private List products = new List(); /// /// 所有原料 /// public List Product { get { return products; } set { products = value; RaisePropertyChanged(); } } /// /// StuffViewModeldl /// public StuffViewModel() { products = new ProductProvider().Select(); DispatcherTimer timer = new DispatcherTimer();//每0.5秒调用一次Tick_Event timer.Interval = TimeSpan.FromSeconds(0.1); timer.Tick += Tick_Event; timer.Start(); } void Tick_Event(object sender, EventArgs e)//Tick_Event周期执行事件 { if (StuffView.Button_sql == true)//获取按钮状态 { Product = new ProductProvider().Select();//扫描数据库 StuffView.Button_sql = false;//清除按钮状态 } } } }