winform 、WPF傳值方式詳解


1.構造函數

2.靜態變量

3.增加窗體屬性

public string name{set;get;}

例如:

 public partial class Window1 : Window
    {
        public string  name { get; set; }
        public int age { get; set; }
        public Window1()
        {
            InitializeComponent();
        }
    }

傳值:

 private void Button_Click(object sender, RoutedEventArgs e)
        {
            Window1 win = new Window1();
            win.name = "xiaohuang";
            win.age = 18;
            win.Show();
        }

 

令附快捷建立屬性方法,使用代碼片段1:簡單屬性,prop

                                                 2:完整屬性:propfull

 

然后按兩次Tab完成,再按Tab改類型,再按Tab改屬性名。

4.使用Application.Current.Properties

傳值方式:
//賦值:
Application.Current.Properties["bbb"] = "dsfds";

//取值:
  string aa = Application.Current.Properties["bbb"].ToString();

 

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM