将属性从运行线程设置为Caliburn Micro中的ViewModel

时间:2015-11-22 20:33:47

标签: c# wpf multithreading mvvm caliburn.micro

我是Caliburn.Micro的初学者,所以如果有什么不清楚或者这个实现是错误的,请告诉我。我有DataGridViewModel个属性NameData

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);
        }
    }
}

以及包含属性MainViewModelFitness的{​​{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()

所以我需要在线程运行期间在我的视图中显示这些字段的实际值。谁能用正确的方法告诉我如何做到这一点?

0 个答案:

没有答案