7 changed files with 200 additions and 62 deletions
@ -0,0 +1,82 @@ |
|||
using formula_manage.SQLModels; |
|||
using formula_manage.Windows; |
|||
using GalaSoft.MvvmLight; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Collections.ObjectModel; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using System.Windows.Threading; |
|||
|
|||
namespace formula_manage.ViewModel |
|||
{ |
|||
///<Summary>
|
|||
/// RRODUCTiewModel
|
|||
///</Summary>
|
|||
public class MainWindowViewModel : ViewModelBase |
|||
{ |
|||
|
|||
|
|||
public MainWindowViewModel() |
|||
{ |
|||
BarCollection = new ObservableCollection<BarModel> |
|||
{ |
|||
new BarModel { Id = 1, Name = "Bar 1", }, |
|||
new BarModel { Id = 2, Name = "Bar 2", }, |
|||
new BarModel { Id = 3, Name = "Bar 3", }, |
|||
}; |
|||
|
|||
FooCollection = new ObservableCollection<FooViewModel> |
|||
{ |
|||
new FooViewModel{ Id = 1, }, |
|||
new FooViewModel{ Id = 2, }, |
|||
new FooViewModel{ Id = 3, }, |
|||
}; |
|||
|
|||
} |
|||
|
|||
public ObservableCollection<BarModel> BarCollection { get; set; } |
|||
public ObservableCollection<FooViewModel> FooCollection { get; set; } |
|||
} |
|||
|
|||
public class FooViewModel : ViewModelBase |
|||
{ |
|||
private BarModel _bar; |
|||
|
|||
public int Id { get; set; } |
|||
public BarModel Bar { get => _bar; set => Set(ref _bar, value); } |
|||
} |
|||
|
|||
public class BarModel |
|||
{ |
|||
public int Id { get; set; } |
|||
public string Name { get; set; } |
|||
|
|||
public override string ToString() |
|||
{ |
|||
return Name; |
|||
} |
|||
|
|||
|
|||
/// <summary>
|
|||
/// StuffViewModeldl
|
|||
/// </summary>
|
|||
/* public RRODUCTiewModel() |
|||
{ |
|||
//products = new ProductProvider().Select();
|
|||
DispatcherTimer timer = new DispatcherTimer//初始化循环,每0.5秒调用一次Tick_Event
|
|||
{ |
|||
Interval = TimeSpan.FromSeconds(0.1) |
|||
}; |
|||
timer.Tick += Tick_Event; |
|||
timer.Start(); |
|||
} |
|||
|
|||
void Tick_Event(object sender, EventArgs e)//Tick_Event周期执行事件
|
|||
{ |
|||
|
|||
}*/ |
|||
|
|||
} |
|||
} |
|||
@ -1,38 +0,0 @@ |
|||
using formula_manage.SQLModels; |
|||
using formula_manage.Windows; |
|||
using GalaSoft.MvvmLight; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using System.Windows.Threading; |
|||
|
|||
namespace formula_manage.ViewModel |
|||
{ |
|||
///<Summary>
|
|||
/// RRODUCTiewModel
|
|||
///</Summary>
|
|||
public class RRODUCTiewModel : ViewModelBase |
|||
{ |
|||
/// <summary>
|
|||
/// StuffViewModeldl
|
|||
/// </summary>
|
|||
public RRODUCTiewModel() |
|||
{ |
|||
//products = new ProductProvider().Select();
|
|||
DispatcherTimer timer = new DispatcherTimer//初始化循环,每0.5秒调用一次Tick_Event
|
|||
{ |
|||
Interval = TimeSpan.FromSeconds(0.1) |
|||
}; |
|||
timer.Tick += Tick_Event; |
|||
timer.Start(); |
|||
} |
|||
|
|||
void Tick_Event(object sender, EventArgs e)//Tick_Event周期执行事件
|
|||
{ |
|||
|
|||
} |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
using CommonServiceLocator; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using GalaSoft.MvvmLight; |
|||
using GalaSoft.MvvmLight.Ioc; |
|||
|
|||
namespace formula_manage.ViewModel |
|||
{ |
|||
public class ViewModelLocator |
|||
{ |
|||
public ViewModelLocator() |
|||
{ |
|||
ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); |
|||
|
|||
////if (ViewModelBase.IsInDesignModeStatic)
|
|||
////{
|
|||
//// // Create design time view services and models
|
|||
//// SimpleIoc.Default.Register<IDataService, DesignDataService>();
|
|||
////}
|
|||
////else
|
|||
////{
|
|||
//// // Create run time view services and models
|
|||
//// SimpleIoc.Default.Register<IDataService, DataService>();
|
|||
////}
|
|||
|
|||
SimpleIoc.Default.Register<MainWindowViewModel>(); |
|||
} |
|||
|
|||
public MainWindowViewModel Main |
|||
{ |
|||
get |
|||
{ |
|||
return ServiceLocator.Current.GetInstance<MainWindowViewModel>(); |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
|||
} |
|||
Loading…
Reference in new issue