viewmodel.cs
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
namespace mvvmtest.ViewModel
{
public class MainViewModel : ViewModelBase
{
///
/// Initializes a new instance of the MainViewModel class.
///
public MainViewModel()
{
Temp = 80;
doCmd = new RelayCommand(dowmtemp);
}
private int myVar;
public int MyProperty
{
get { return myVar; }
set { myVar = value; }
}
public int temp;
public int Temp
{
get { return temp; }
set { temp = value; RaisePropertyChanged(); }
}
private RelayCommand doCmd;
public RelayCommand DoCmd
{
get { return doCmd; }
set { doCmd = value; }
}
private void dowmtemp()
{
System.Windows.MessageBox.Show(temp.ToString());
}
//private int myvar;
//public int MyProperty
//{
// get { return myvar; }
// set { myvar = value; }
//}
}
}
xmal
xmal.cs
namespace mvvmtest
{
///
/// MainWindow.xaml 的交互逻辑
///
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.DataContext = new ViewModel.MainViewModel();
}
}
}
data.cs
namespace mvvmtest.Model
{
public class data
{
public int Temp { get; set; }
public int Current { get; set; }//dianliu
public int dianya { get; set; }
}
}



