如何让列表框项目在被选中时拉伸列表框的整个高度。我的情况就像我的列表框项目包含一个扩展器,它扩展并显示另一个列表。第二个列表框很长,我正在寻找一些方法来防止用户滚动很多。我正在寻找某种方法来为第二个列表框提供整个可用高度。任何输入将不胜感激。提前致谢。
1318 次
1 回答
3
我不确定我的想法是否正确,但试试这个:
<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>
于 2010-12-09T12:11:28.683 回答