关闭ComboBox循环滚动

时间:2016-06-17 11:32:48

标签: combobox winrt-xaml

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

如何删除此循环滚动功能,以便用户到达列表末尾?

我的代码:

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

1 个答案:

答案 0 :(得分:2)

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

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

//Original
angular.module('pageModule')
.controller('pageController', ['$scope', 'homeService', 'pageService', function($scope, homeService, pageService){

  $scope.pages = pageService.pagesArray;

  pageService.load();

}]);

//Changed
angular.module('pageModule')
.controller('pageController', ['$scope', 'homeService', 'pageService', function($scope, homeService, pageService){

  $scope.pages = [] //Initiale state;

  //Make use of the HTTP promise that is returned in the load
  pageService.load()
    .then(function (pages) {
      $scope.pages = pages;
    })
    .catch(function (error) {
      //Handle error
      console.log(error);
    });

}]);

这是编辑面板模板,因此您的最终代码将是:

 <ComboBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Vertical" />
                </ItemsPanelTemplate>
 </ComboBox.ItemsPanel>
相关问题