我需要能夠在運行時創建動態控件 - textblocks,按鈕是特定的。我試過這個: dim b as button = new button b.content =「test」Win Phone 8 WP8在運行時創建動態控件
代碼沒有錯誤,但也不會產生按鈕。簡單的我知道,但對於Wp8來說,這對我來說非常困難。 謝謝
我需要能夠在運行時創建動態控件 - textblocks,按鈕是特定的。我試過這個: dim b as button = new button b.content =「test」Win Phone 8 WP8在運行時創建動態控件
代碼沒有錯誤,但也不會產生按鈕。簡單的我知道,但對於Wp8來說,這對我來說非常困難。 謝謝
你仍然需要添加按鈕到你的頁面。試試這個:
的XAML
<ContentControl x:Name="container">
</ContentControl>
代碼
Dim b as New Button With { .Content = "test"}
container.Content = b
謝謝你,好極了。我嘗試添加一個Click處理程序:AddHandler b.Click,AddressOf b_click其中調用方法Private Sub b_click(sender As Object,e As RoutedEventArgs) MessageBox.Show(「Clicked」+ sender.ToString + e.ToString) End子,但它沒有觸發點擊方法。 – user2380522 2013-05-14 07:43:25
你到底想幹什麼?從後臺代碼創建控件通常不是最好的方法。 – vonLochow 2013-05-14 07:26:29