0

我有一个 WPF 项目,它是解决方案的一部分,它是“ProjectFilesSelector”。一个名为 A 的项目,调用 ProjectFilesSelector 如下图:

!!!更新:

namespace ProjectFilesSelector
{
   ...
   public class ViewModel 
   {
        ...
        public ICommand cancel
        {
            get
            {
                return new WPFExtensions.RelayCommand(_ =>
                    {
                        this.window.Visibility = Visibility.Hidden;
                        this.window.Close();
}); } }
}

public partial class Window1 : Window, IDisposable { public Window1(ProjectTypes.Project pro) { InitializeComponent();

        var context = new ViewModel(this, new ATChecker.ViewModel.ProjectModel(pro));
        this.DataContext = context;
    }

... }

}

namespace ATCheckerView { public class ViewerClientExt : INotifyPropertyChanged { ...

public ICommand CheckPrinciplies { get { var cmnd = new RelayCommand(project => { var proj = (ViewModel.ProjectModel)project; ProjectFilesSelector.ViewModel dc; using (var a = new ProjectFilesSelector.Window1(proj.project)) { a.ShowDialog(); // cancel command was called dc = (ProjectFilesSelector.ViewModel)a.DataContext; } .... // some code // and I can still see the window of Window1. Why? });

4

1 回答 1

1

我认为您不想退出该应用程序。您可能只想关闭窗口。取消按钮只是将 IsCancel 设置为 true。对于 ok 按钮,最好的方法是在视图模型中创建一个事件以进入视图。

于 2012-08-22T09:51:57.933 回答