比如我们在做登录的时候需要关闭父窗体打开子窗体.使用Caliburn.Micro它的时候我们关闭登录窗口的时候主页面也会关闭. 解决方法就是在登录页面的CS里面写 IndexView iv = new IndexView();//主窗体 this.Close();//关闭登录页面 iv.ShowDialog();//打开主窗体 这3句话只能在CS里面写,在ViewModel里面是不可能的.原因很简单,View引用ViewModel.我们都知道CM的协议会自动给我们关联View和VIewMode,
WinForm如果我们希望一次只打开一个程序,那么我们在程序每次运行的时候都需要检测线程是否存在该程序,如果存在就呼出之前的窗体,C#代码如下: using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.InteropServices; using System.Windows.