【问题标题】:How to get the wpf listboxitem to stretch entire height of listbox when selected选择时如何让wpf listboxitem拉伸列表框的整个高度
【发布时间】:2010-12-19 23:00:15
【问题描述】:

如何让列表框项目在被选中时拉伸列表框的整个高度。我的情况就像我的列表框项目包含一个扩展器,它扩展并显示另一个列表。第二个列表框很长,我正在寻找一些防止用户滚动的方法。我正在寻找一些方法来为第二个列表框提供整个可用高度。任何输入将不胜感激。提前致谢。

【问题讨论】:

    标签: wpf listbox resize height listboxitem


    【解决方案1】:

    我不确定我的想法是否正确,但试试这个:

        <ListBox>
            <ListBox.ItemContainerStyle>
                <Style TargetType="ListBoxItem">
                    <Style.Triggers>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="Height" Value="{Binding Path=ActualHeight, RelativeSource={RelativeSource AncestorType={x:Type ListBox}}}"/>
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </ListBox.ItemContainerStyle>
            <ListBoxItem>1</ListBoxItem>
            <ListBoxItem>2</ListBoxItem>
            <ListBoxItem>3</ListBoxItem>
        </ListBox>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-02-14
      • 2015-07-12
      • 2022-08-18
      • 1970-01-01
      • 2011-06-18
      • 2022-01-15
      • 1970-01-01
      相关资源
      最近更新 更多