我是Caliburn.Micro的初学者,所以如果有什么不清楚或者这个实现是错误的,请告诉我。我有DataGridViewModel
个属性Name
,Data
class DataGridViewModel : Screen
{
private char name;
public char Name
{
get { return name; }
set
{
name = value;
this.NotifyOfPropertyChange(() => Name);
}
}
private DataTable data;
public DataTable Data
{
get { return data; }
set
{
data = value;
this.NotifyOfPropertyChange(() => Data);
}
}
}
以及包含属性MainViewModel
和Fitness
的{{1}}。在GenerationCout
中是一个按钮,用于启动MainView
类的新主题。
Genetic
有public class MainViewModel : Conductor<Screen>.Collection.AllActive
{
private Genetic genetic;
private double fitness;
public double Fitness
{
get { return fitness; }
set
{
fitness = value;
NotifyOfPropertyChange(() => Fitness);
}
}
private int generationCout;
public int GenerationCout
{
get { return generationCout; }
set
{
generationCout = value;
NotifyOfPropertyChange(() => GenerationCout);
}
}
public void Start()
{
List<string> features = new List<string> { "(a*b)*c=a*(b*c)" };
genetic = new Genetic(features);
genetic.Start();
}
public MainViewModel()
{
generationCout = 0;
fitness = 0;
}
}
和best
等字段。并且有一个方法generationCount
用于运行此类的线程。在方法中我设置实际字段值,我想将它发送到ViewModels,最终在Views中刷新它。
SetActual()
所以我需要在线程运行期间在我的视图中显示这些字段的实际值。谁能用正确的方法告诉我如何做到这一点?