关闭ComboBox循环滚动 [英] Turning off ComboBox loop scroll

查看:113
本文介绍了关闭ComboBox循环滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ComboBox,可以让用户从列表中进行选择,但是当列表足够长时,它将开始自动环绕。例如,如果用户向下滚动足够远,他们将到达列表的末尾,然后在单个空白行之后找到列表的顶部。下拉选择列表永远不会真正结束,只会一直循环下去。

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?

我的代码:

<ComboBox Name="listSelect" ItemsSource="{Binding DataInstance.ItemList}">
    <ComboBox.ItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding ItemNumber, Mode=OneWay}" />
        </DataTemplate>
    </ComboBox.ItemTemplate>
</ComboBox>


推荐答案

本文中可能的解决方案: http://netitude.bc3tech.net/2013/04/12 / windows-8s-combobox-and-the-carouselpanel /

Possible solution from this article: http://netitude.bc3tech.net/2013/04/12/windows-8s-combobox-and-the-carouselpanel/

将此设置为您的ComboBox控件,这将覆盖默认面板:

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> 

这篇关于关闭ComboBox循环滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆