WPF listbox实现多列显示数据


一.每行显示固定列数

<ListBox ItemsSource="{Binding DataList}" Style="{DynamicResource ListBoxStyle}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" >
                    <ListBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <UniformGrid Columns="3"/>
                        </ItemsPanelTemplate>
                    </ListBox.ItemsPanel>
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            ...
                        </DataTemplate>
                    </ListBox.ItemTemplate>
</ListBox>

二.每行显示列数随宽度变化

<ListBox ItemsSource="{Binding DataList}" Style="{DynamicResource ListBoxStyle}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" >
                    <ListBox.ItemsPanel>
                        <ItemsPanelTemplate>          
                            <WrapPanel IsItemsHost="True"/>
                        </ItemsPanelTemplate>
                    </ListBox.ItemsPanel>
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            ...
                        </DataTemplate>
                    </ListBox.ItemTemplate>
</ListBox>

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM