包装列表框并展开所选项目 [英] Wrapping Listbox with expanding selected item

查看:68
本文介绍了包装列表框并展开所选项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作一个包装列表框,其中所选项目在其他项目之间内联展开.我到目前为止所得到的:

Im trying to make a Wrapping Listbox, where the selected item is expanded inline in-between the other items. What i got so far:

<Window.Resources>
        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
        <Style x:Key="ListBoxItemStyle" TargetType="{x:Type ListBoxItem}">
            <Setter Property="VerticalAlignment" Value="Top"/>
            <Setter Property="VerticalContentAlignment" Value="Top"/>
        </Style>
    </Window.Resources>
    <StackPanel>
        
        <ListBox x:Name="GoogleImagesList" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ItemContainerStyle="{StaticResource ListBoxItemStyle}">
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapPanel Orientation="Horizontal" IsItemsHost="false" VerticalAlignment="Top">
                    </WrapPanel>
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
            <ListBox.ItemTemplate>
                <DataTemplate DataType="googleImagesList:GoogleImage">
                    <StackPanel>
                        <Label x:Name="ListBoxItemLabel" Content="{Binding Caption}" VerticalAlignment="Top"/>
                        <StackPanel Visibility="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=ListBoxItem}, Path=IsSelected, Converter={StaticResource BooleanToVisibilityConverter}}">
                            <Label>Details of the selected item</Label>
                            <Label>The heigh of the this stackpanel, decides when the next row start in the ListBox</Label>
                        </StackPanel>
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </StackPanel>

我的问题是:

1:无论选择该项时显示的堆栈面板的宽度如何,ListBoxItem的宽度都必须保持不变.

1: The ListBoxItem must remain the same width, regardless the width of the stackpanel shown when item is selected.

2:StackPanel必须仅用ListBox填充整个内容.

2: The StackPanel must fill the entire with of the ListBox only.

主意是获取包装物品清单,例如Google在其图片搜索中制作的物品.我尝试用Popup控件和Canvas替换stackPanel,然后尝试在ListBoxItem上创建触发器以根据 弹出窗口/画布,但似乎无法正确触发该操作.

The idear is to get a List of wrapping items like the one google made in their image search. I have tried replacing the stackPanel with a Popup control and a Canvas, and then tried to make a trigger on the ListBoxItem to change the height according to the popup/canvas, but cant seem to get a proper trigger to do the trick.

和我有想法的人,因为我快没精了.

Any bright mind with and idear, because i am running out.

致谢

推荐答案

看看这个线程:

Have a look at this thread:

http://stackoverflow.com/questions/1299824/listbox-expand-selected-item


这篇关于包装列表框并展开所选项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆