2012-04-17 14 views

回答

1

那你怎麼做:

//To Set:  
App.Current.Properties["TextBoxString"] = textBox1.Text; 
//To Get: 
string myProperty = (string) App.Current.Properties["TextBoxString"]; 

退房此文出於Accessing the Application object in a WPF application

+0

但如果我把'App.Current.Properties [ 「TextBoxString」] = textBox1.Text;'當我在我的自定義控件中放置字符串'myProperty = App.Current.Properties [「TextBoxString」];'它說不能隱式地將對象轉換爲字符串時,在我的主窗口頁面上的按鈕中輸入 ? – 2012-04-17 16:49:36

+1

@KirstyWhite剛剛編​​輯了答案,您需要先將其轉換爲字符串,然後再將其分配給myProperty – Habib 2012-04-17 16:52:53

相關問題