C# 委托事件
2021-03-13 15:37
                         标签:string   rgs   sub   tar   oid   int   window   one   eve     public partial class SubWindow : Window         public event PassValuesHandler PassValuesEvent;          public SubWindow()         private void btnOK_Click(object sender, RoutedEventArgs e)             PassValuesEventArgs args = new PassValuesEventArgs(value1, value2);             this.Close();         private void btnOpenSubWindow_Click(object sender, RoutedEventArgs e)             // 订阅事件             subWindow.Show();          private void ReceiveValues(object sender, PassValuesEventArgs e) C# 委托事件 标签:string   rgs   sub   tar   oid   int   window   one   eve    原文地址:https://www.cnblogs.com/jeenmablog/p/12530780.html
    {
        public delegate void PassValuesHandler(object sender, PassValuesEventArgs e);
        {
            InitializeComponent();
        }
        {
            string value1 = tbValue1.Text;   // Text Property return value is string type .
            int value2;
            Int32.TryParse(tbValue2.Text, out value2);
            if ( PassValuesEvent!=null)
           {
              PassValuesEvent(this, args);
            } 
        }
    }
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
        {
            SubWindow subWindow = new SubWindow(); 
            subWindow.PassValuesEvent += new SubWindow.PassValuesHandler(ReceiveValues);
        }
        {
            this.tbValue1.Text = e.Value1;
            this.tbValue2.Text = e.Value2.ToString(); 
        }
    }