locked
ComboBox behaviour RRS feed

  • Question

  • Hi all,

    I have a to display some birthdays when creating an account for an Windows 8 App so I am using ComboBox for displaying the years , months and days. When you get to the end of the lists by scrolling it shows again the list from the start.

    I understand that this is the normal behaviour but i would like not to have an infinite loop when scrolling. Is there a solution  or I have to use something else?

    Thank you!

    Wednesday, July 3, 2013 9:45 AM

Answers

  • Hi,

    I was telling about ItemsPanelTemplate of ComboBox and not about having your ComboBoxes inside a StackPanel

    Try this code...

    <StackPanel Orientation="Horizontal" Margin="0 5 0 15">

    <ComboBox ItemsSource="{Binding Months}" SelectedItem="{Binding Month, Mode=TwoWay}"IsEnabled="{Binding CreatingAccount, Converter={StaticResourceInverseBooleanConverter}}" Margin="0 0 10 0">

    <ItemsPanelTemplate>

           <StackPanel />

    </ItemsPanelTemplate>

    </ComboBox>

    <ComboBox ItemsSource="{Binding Days}" SelectedItem="{Binding Day, Mode=TwoWay}"Name="cmbDay" IsEnabled="{Binding CreatingAccount, Converter={StaticResourceInverseBooleanConverter}}" Margin="0 0 10 0">

    <ItemsPanelTemplate>

           <StackPanel />

    </ItemsPanelTemplate>

    </ComboBox>

    <ComboBox ItemsSource="{Binding Years}" SelectedItem="{Binding Year, Mode=TwoWay}"IsEnabled="{Binding CreatingAccount, Converter={StaticResourceInverseBooleanConverter}}" Width="100">

    <ItemsPanelTemplate>

           <StackPanel />

    </ItemsPanelTemplate>

    </ComboBox>

    </StackPanel>

     

    Thanks,

    Roshan

    Friday, July 12, 2013 10:12 AM

All replies

  • Hi adrianadrianp,

    I tried to implement the ComboBox with large amount of items, but I did not see any infinite loop while scrolling.

    Can you show the code snappet with me?


    James He
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, July 9, 2013 5:45 AM
    Moderator
  • Hi,

    By default the ItemsPanelTemplate of a ComboBox is a CarouselPanel; this causes the infinite scrolling.

    To fix this issue change ItemsPanelTemplate of your ComboBox to StackPanel.

    Thanks,

    Roshan

    • Proposed as answer by Roshan Routray Wednesday, July 10, 2013 3:27 AM
    Tuesday, July 9, 2013 6:33 AM
  • Hi . Thanks for the answers.

    <StackPanel Orientation="Horizontal" Margin="0 5 0 15">

    <ComboBox ItemsSource="{Binding Months}" SelectedItem="{Binding Month, Mode=TwoWay}" IsEnabled="{Binding CreatingAccount, Converter={StaticResource InverseBooleanConverter}}" Margin="0 0 10 0"></ComboBox>

    <ComboBox ItemsSource="{Binding Days}" SelectedItem="{Binding Day, Mode=TwoWay}" Name="cmbDay" IsEnabled="{Binding CreatingAccount, Converter={StaticResource InverseBooleanConverter}}" Margin="0 0 10 0"></ComboBox>

    <ComboBox ItemsSource="{Binding Years}" SelectedItem="{Binding Year, Mode=TwoWay}" IsEnabled="{Binding CreatingAccount, Converter={StaticResource InverseBooleanConverter}}" Width="100"></ComboBox>

    </StackPanel>

    I am using  a StackPanel . This is my code.

    The infinite scrolling happens just on surface RT not on Desktop.

    Thanks !

    Thursday, July 11, 2013 8:25 AM
  • Hi,

    I was telling about ItemsPanelTemplate of ComboBox and not about having your ComboBoxes inside a StackPanel

    Try this code...

    <StackPanel Orientation="Horizontal" Margin="0 5 0 15">

    <ComboBox ItemsSource="{Binding Months}" SelectedItem="{Binding Month, Mode=TwoWay}"IsEnabled="{Binding CreatingAccount, Converter={StaticResourceInverseBooleanConverter}}" Margin="0 0 10 0">

    <ItemsPanelTemplate>

           <StackPanel />

    </ItemsPanelTemplate>

    </ComboBox>

    <ComboBox ItemsSource="{Binding Days}" SelectedItem="{Binding Day, Mode=TwoWay}"Name="cmbDay" IsEnabled="{Binding CreatingAccount, Converter={StaticResourceInverseBooleanConverter}}" Margin="0 0 10 0">

    <ItemsPanelTemplate>

           <StackPanel />

    </ItemsPanelTemplate>

    </ComboBox>

    <ComboBox ItemsSource="{Binding Years}" SelectedItem="{Binding Year, Mode=TwoWay}"IsEnabled="{Binding CreatingAccount, Converter={StaticResourceInverseBooleanConverter}}" Width="100">

    <ItemsPanelTemplate>

           <StackPanel />

    </ItemsPanelTemplate>

    </ComboBox>

    </StackPanel>

     

    Thanks,

    Roshan

    Friday, July 12, 2013 10:12 AM