我在我的DataGrid
中有一個Expander
,但我只想顯示兩個項目,然後當用戶單擊展開時,顯示剩餘的項目。wpf datagrid擴展器顯示x項目
如何做到這一點?
<DataGrid.GroupStyle>
<GroupStyle AlternationCount="7" >
<GroupStyle.ContainerStyle>
<Style TargetType="{x:Type GroupItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GroupItem}">
<Expander IsExpanded="False" Background="{Binding XPath=recipient_color}">
<Expander.Header>
<Label Content="{Binding}">
</Label>
</Expander.Header>
<Expander.Content>
<ItemsPresenter/>
</Expander.Content>
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
</GroupStyle>
</DataGrid.GroupStyle>
你可以舉一個例子如何實現? – keno
@keno基本上所有你需要做的就是從我給你的鏈接(包括底部的資源)複製所有的xaml並將其轉儲到你的DataGrid.Resources中。然後將ContentRow的高度從0改爲任何值。問題是模板可能與您當前的主題不匹配,並且很難找到正確的起始模板。但它值得一試。 – Jelly
Hahahahaha IT WORKED !!!! :D它確實與原始模板不一樣(標題的背面顏色是藍色/紫色等)。但我會改變這個mannualy;)謝謝! – keno