zoukankan      html  css  js  c++  java
  • SilverLight 4 学习笔记一 —— ChildWindow 向主窗口传递值的方法

    ChildWindow:

            private string _test; 
    
            public string Test //测试属性
            {
                get { return _test; }
                set {_test = value; }
            }
    
            public event EventHandler OkBtnClicked;//新建事件,在点击ok button时,事件初始化 
    
            private void OKButton_Click(object sender, RoutedEventArgs e)
            {
                if (OkBtnClicked != null)
                {
                    OkBtnClicked(this, new EventArgs());
                    _test = "test";
                }
                this.DialogResult = true;//只有在true时窗口才可以关闭,如果为fals
            }

    FatherWindow:

            ChildWindow1 childwin = new ChildWindow1();//针对子窗口的引用
    
            public MainPage()
            {
                InitializeComponent();           
    
                childwin.Closed += new EventHandler(childwin_Closed); //监听子窗口的关闭,在要求不高时,个人觉得也可以采用这种较为简单的方法
                childwin.OkBtnClicked += new EventHandler(childwin_OkBtnClicked);//监听子窗口的ok按钮
            }       
    
            private void childwin_OkBtnClicked(object sender, EventArgs e)
            {
                MessageBox.Show(childwin.Test);
            } 
    
            private void childwin_Closed(object sender, EventArgs e)
            {
                MessageBox.Show(childwin.Test);
            }
  • 相关阅读:
    129. Sum Root to Leaf Numbers
    113. Path Sum II
    114. Flatten Binary Tree to Linked List
    112. Path Sum
    100. Same Tree
    300. Longest Increasing Subsequence
    72. Edit Distance
    自定义js标签库
    JS 实现Table相同行的单元格自动合并示例代码
    mysql 高版本only_full_group_by 错误
  • 原文地址:https://www.cnblogs.com/smallidea/p/2573173.html
Copyright © 2011-2022 走看看