窗体之间的交互,传值,关闭登录窗口

1.          //关闭登陆窗口
            foreach (Window window in Application.Current.Windows)
            {
                if (window.Title == "LoginWindow")
                {
                    window.Close();
                }
            }

2.       通过构造函数传值,调用引用获取返回值

            RenameDialog dialog = new RenameDialog(Path.GetFileNameWithoutExtension(filename));
            if (dialog.ShowDialog() == true) // Result could be true, false, or null
            {
                // Attempt to rename the file
                try
                {
                    File.Move(filename, Path.Combine(Path.GetDirectoryName(filename), dialog.NewFilename) + Path.GetExtension(filename));
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Cannot Rename File", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }

posted @ 2013-01-19 23:36  gitran  阅读(148)  评论(0编辑  收藏  举报