zoukankan      html  css  js  c++  java
  • 收藏 Silverlight中子窗体关闭刷新父窗体(转载)


        public partial class MainPage : UserControl
        {
            public MainPage()
            {
                InitializeComponent();
            }
            private void Button_Click(object sender, RoutedEventArgs e)
            {
                LoginWindow loginWnd = new LoginWindow();
                loginWnd.Closed += new EventHandler(loginWnd_Closed);
                loginWnd.Show();
            }
            void loginWnd_Closed(object sender, EventArgs e)
            {
                LoginWindow lw = (LoginWindow)sender;

                if (lw.DialogResult == true && lw.nameBox.Text != string.Empty)
                {
                    this.helloTxt.Text = "Hello " + lw.nameBox.Text;
                }
                else if (lw.DialogResult == false)
                {
                    this.helloTxt.Text = "Login canceled.";
                }
            }
        }

        public partial class LoginWindow : ChildWindow
        {
            public LoginWindow()
            {
                InitializeComponent();
            }
            private void OKButton_Click(object sender, RoutedEventArgs e)
            {
                this.DialogResult = true;
            }

            private void CancelButton_Click(object sender, RoutedEventArgs e)
            {
                this.DialogResult = false;
            }
            private void ChildWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
            {
                if (this.DialogResult == true &&
                        (this.nameBox.Text == string.Empty || this.passwordBox.Password == string.Empty))
                {
                    e.Cancel = true;
                    ChildWindow cw = new ChildWindow();
                    cw.Content = "Please enter name and password or click Cancel.";
                    cw.Show();
                }
            }
        }
  • 相关阅读:
    全屏透明遮罩层
    理解Javascript__理解undefined和null
    JS 对象属性相关--检查属性、枚举属性等
    js 空正则匹配任意一个位置
    a 标签 download 和 target 不配合
    Array.prototype.filter(Boolean)
    页面操作表单不会调用表单 value 属性的 set 函数
    Babel6.x的安装
    html 事件处理程序中的代码在执行时,有权访问全局作用域中的任何代码。
    js 常用 DOM 元素宽高
  • 原文地址:https://www.cnblogs.com/sandea/p/3289878.html
Copyright © 2011-2022 走看看