在UWP開發中遇到個小問題,ComboBox的Item太多的話,列表會重複,並且無限循環,Google了一下後發現這貌似是Metro應用的老問題了,由於ComboBox的Items使用的是CarouselPanel而導致的。
解決方法:改變ComboBox的ItemsPanelTemplate爲StackPanel
<ComboBox>
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>
目前發現了這樣做的一個問題,ComboBox選擇非第一項的選項之後再選擇第一項,會出現變成空白,或選不了的bug,暫時沒有發現解決辦法。
參考:http://netitude.bc3tech.net/2013/04/12/windows-8s-combobox-and-the-carouselpanel/