zoukankan      html  css  js  c++  java
  • WPF ListBox 实现多行多列定制内容显示

    效果如图

    关键代码

    <ListBox Name="imageListBox" ItemsSource="{Binding }"
                Width="{Binding ElementName=listBoxShowImages,Path=Width,Mode=OneWay}" Loaded="imageListBox_Loaded">
        <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
                <UniformGrid Columns="6"/>
            </ItemsPanelTemplate>
        </ListBox.ItemsPanel>
        <!--定制样式-->
        <ListBox.ItemTemplate>
            <DataTemplate>
                <StackPanel Orientation="Vertical">
                    <TextBlock Margin="3" Text="{Binding Name}" Width="100"/>
                    <Image Margin="3" Source="{Binding Path}" Width="100" Height="100"/>
                </StackPanel>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>
    

    单行Item个数设置

    <UniformGrid Columns="6"/>
    

    示例代码

    ListBoxShowImages

  • 相关阅读:
    SPOJ
    基础计算几何
    数颜色
    Codeforces 986B
    一些有趣的题
    jQuery
    linux命令学习
    javaScript
    css
    html
  • 原文地址:https://www.cnblogs.com/Lulus/p/14124052.html
Copyright © 2011-2022 走看看