我想在Windows Phone的ListBox的末尾添加一個「all items」按鈕。
我該怎麼做?Windows Phone使用不同的DataTemplate將項目添加到ListBox的末尾?
我想讓它的DataTemplate與其他ListBox項目不同!
我想在Windows Phone的ListBox的末尾添加一個「all items」按鈕。
我該怎麼做?Windows Phone使用不同的DataTemplate將項目添加到ListBox的末尾?
我想讓它的DataTemplate與其他ListBox項目不同!
使用ItemTemplateSelector
女巫基於項目類型將顯示不同DataTemplate
。
你可以按照下面的指南:
http://www.geekchamp.com/articles/implementing-windows-phone-7-datatemplateselector-and-customdatatemplateselector
不要使用項模板選擇爲:使用它們只是爲了一個按鈕是矯枉過正,除了他們是很難實現和支持。
而應該自定義列表框的控件模板。在混合中,右鍵單擊列表框「編輯模板/編輯副本...」,比在模板中將XAML <ScrollViewer><ItemsPresenter /></ScrollViewer>
更改爲例如<ScrollViewer><StackPanel><ItemsPresenter /><Button Content="all items" /></StackPanel></ScrollViewer>