posts - 36,  comments - 12,  views - 10万
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

希望得到一个多个列的listBox,每个单元都是ListBox的一个Item, 效果图如下:

 

对应的xaml:

复制代码
                    <Grid x:Name="LoginNoSubsPanel" Visibility="Visible">
                        <ListBox x:Name="HotKeywordsListBox"
                                 ItemsSource="{Binding RecommendedTopicsLeft}">
                            <ListBox.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <toolkit:WrapPanel  ItemHeight="176" ItemWidth="176"/>
                                </ItemsPanelTemplate>
                            </ListBox.ItemsPanel>
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <Grid Margin="20,0,0,20">
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="*"/>
                                        </Grid.RowDefinitions>
                                        <Image Grid.Row="0" Source="{Binding ImageSource}" 
                                               Height="140" Width="176" Margin="0"
                                               Stretch="Uniform"/>
                                        <Button Grid.Row="0" HorizontalAlignment="Center" 
                                                VerticalAlignment="Center" Margin="0" Padding="0"
                                                BorderThickness="0">
                                            <Button.Content>
                                                <Image Source="/Assets/BtnIcons/unchoose_2.png"
                                                       Width="36" Height="36"/>
                                            </Button.Content>
                                        </Button>
                                        <TextBlock Grid.Row="1" Text="{Binding KeyWords}" 
                                               FontSize="{StaticResource PhoneFontSizeNormal}"/>
                                        <Rectangle Grid.RowSpan="2" Stroke="Gray"/>
                                    </Grid>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                    </Grid>
复制代码

设置ItemsPanel, 用到了 toolkit:WrapPanel.

posted on   桃源月色  阅读(582)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
点击右上角即可分享
微信分享提示