问题
I have a ComboBox to let the user choose from a list, but when the list gets long enough it begins to automatically wrap around. For example, if the user scrolls far enough down they'll reach the end of the list and then find the top of the list just after a single blank row. The drop down selection list never really ends, it just keeps looping forever.
How can I remove this looping scroll feature so the user just reaches the end of list?
My code:
<ComboBox Name="listSelect" ItemsSource="{Binding DataInstance.ItemList}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding ItemNumber, Mode=OneWay}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
回答1:
Possible solution from this article: http://netitude.bc3tech.net/2013/04/12/windows-8s-combobox-and-the-carouselpanel/
Set this to your ComboBox control, this should overwrite the default panel:
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical" />
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
This is to edit the panel template, so your final code will be:
<ComboBox Name="listSelect" ItemsSource="{Binding DataInstance.ItemList}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding ItemNumber, Mode=OneWay}" />
</DataTemplate>
</ComboBox.ItemTemplate>
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical" />
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>
来源:https://stackoverflow.com/questions/37880522/turning-off-combobox-loop-scroll