none
online shopping site

    質問

  • i have used listbox to diplay multiple items.but the thing is its displaying whole items only in a single line and i want multiple rows.

    like first 10 items in first line then when listbox's width gets finished then items shold start from the next line. 

    2012年6月12日 4:07

回答

  • i already tried using wrappanel but it was not working.

    Hey Glimpse,

    It will work, i am using in my curent project, you make sure that you keep HorizontalScrollBarVisibility to disabled, check my code.

    2012年6月12日 5:17

すべての返信

  • like first 10 items in first line then when listbox's width gets finished then items shold start from the next line.

    ListBox add its item in stackpanel and its orientation is vertical you can make it horizontal too, by adding stackpanel in itemtemplate.

    if you want items as horizontally and items to wrapped, then you have to add itematemplate as wrappanel, follow my sample code below, make sure that you disable horizontal scrollbar, let me know if anything else needed.

      <ListBox x:Name="LstBxDetailView" Grid.Row="6" Grid.Column="1" Grid.ColumnSpan="4"  Background="LightGray" Style="{StaticResource ListBoxStyle1}" ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                     ItemContainerStyle="{StaticResource myLBStyle}" 
                      SelectionChanged="LstBxDetailViewSelectionChanged">
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel Orientation="Horizontal"/>
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
            </ListBox>



    2012年6月12日 4:52
  • i already tried using wrappanel but it was not working.

    2012年6月12日 5:15
  • i already tried using wrappanel but it was not working.

    Hey Glimpse,

    It will work, i am using in my curent project, you make sure that you keep HorizontalScrollBarVisibility to disabled, check my code.

    2012年6月12日 5:17
  • yes its working ....i was not disabling horizontal scrollbar visibility.

    thank you.

    2012年6月12日 6:32