它聽起來並不像擴展器,你應該使用此方案的控制。擴展有一個頭和內容,如:
<Expander Header="Visible all the time">
<TextBlock Text="Hidden until expanded" />
</Expander>
它像你想的是被設置爲一個特定的高度一些時間控制的聲音,我和在其他時間奔放。
我認爲你可以通過綁定一個ToggleButton
(Expander在內部使用)來達到MaxHeight
屬性ListBox
。
嘗試這樣的事情在Kaxaml:
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:diag="clr-namespace:System.Diagnostics;assembly=System">
<Page.Resources>
<!-- A way of getting some test data in Kaxaml -->
<ObjectDataProvider x:Key="Processes"
MethodName="GetProcesses"
ObjectType="{x:Type diag:Process}" />
</Page.Resources>
<StackPanel>
<ToggleButton Name="Expand" Content="Expand" />
<ListBox Name="lstProcesses"
ItemsSource="{Binding Source={StaticResource Processes}}"
DisplayMemberPath="ProcessName">
<ListBox.Style>
<Style TargetType="ListBox">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=Expand, Path=IsChecked}"
Value="False">
<Setter Property="MaxHeight" Value="60" />
</DataTrigger>
</Style.Triggers>
</Style>
</ListBox.Style>
</ListBox>
</StackPanel>
</Page>
你喜歡在擴展頭中顯示該內容嗎? – 2009-07-28 05:53:16