Home:ALL Converter>ItemsControl Wrapping

ItemsControl Wrapping

Ask Time:2014-11-13T00:10:21         Author:ribald

Json Formatter

I have a list of dynamic data that needs to display in the following manner:

1  4  7  10
2  5  8  11
3  6  9  12

13 16 19 22
14 17 20 23
15 18 21 24
...

However my code only iterates the top portion and runs off the screen. The following code is inside a grid. What am I doing wrong?

          <toolkit:WrapPanel Orientation="Vertical" Grid.Row="2" >
                <ItemsControl ItemsSource="{Binding ImagingTypes, Mode=TwoWay}" 
                              Margin="5">
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                                <toolkit:WrapPanel Orientation="Vertical"/>
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" Margin="5,0,5,0">
                                <CheckBox IsChecked="{Binding IsSelected, Mode=TwoWay}" VerticalAlignment="Top" />
                                <TextBlock Grid.Column="1" Text="{Binding Description}" MaxWidth="150" TextWrapping="Wrap" />
                            </StackPanel>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </toolkit:WrapPanel>

Author:ribald,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/26891458/itemscontrol-wrapping
MLElyakan :

Sorry.I don't know very well English so I couldn't understand exactly what you mean.But If you want a sequence as above and If you want to remain static position of items.You can use UniformGrid . I hope this is what you're looking for.\n\nHere is code:\n\nI did a listview sample;\n\n <ListView x:Name=\"SharedSizeScopeListView\">\n <ListView.ItemsPanel>\n <ItemsPanelTemplate > \n <UniformGrid IsItemsHost=\"True\" Columns=\"4\"/>\n </ItemsPanelTemplate>\n </ListView.ItemsPanel>\n <ListViewItem Content=\"1\"/>\n <ListViewItem Content=\"4\"/>\n <ListViewItem Content=\"7\"/>\n <ListViewItem Content=\"10\"/>\n\n <ListViewItem Content=\"2\"/>\n <ListViewItem Content=\"5\"/>\n <ListViewItem Content=\"8\"/>\n <ListViewItem Content=\"11\"/>\n\n <ListViewItem Content=\"3\"/> \n <ListViewItem Content=\"6\"/> \n <ListViewItem Content=\"9\"/> \n <ListViewItem Content=\"12\"/>\n\n <ListViewItem Content=\"13\"/>\n <ListViewItem Content=\"16\"/>\n <ListViewItem Content=\"19\"/>\n <ListViewItem Content=\"22\"/>\n\n <ListViewItem Content=\"14\"/>\n <ListViewItem Content=\"17\"/>\n <ListViewItem Content=\"20\"/>\n <ListViewItem Content=\"23\"/>\n\n <ListViewItem Content=\"15\"/> \n <ListViewItem Content=\"18\"/> \n <ListViewItem Content=\"21\"/> \n <ListViewItem Content=\"24\"/>\n\n </ListView>\n",
2014-11-12T19:05:41
yy