2012-10-10 5 views
3

아래와 같은 목록 상자에 표시해야합니다. 시나리오에는 여러 그룹이 있고 수평으로 정렬 된 항목이 있습니다.WPF 목록 상자 그룹화

GroupA 
     GroupA Description 
    GroupB 
     GroupB Description 
    Items Available 
    ItemA ItemB ITemC 

답변

1

당신은

<Style x:Key="ContainerStyle" TargetType="{x:Type GroupItem}"> 
      <Setter Property="Template"> 
       <Setter.Value> 
        <ControlTemplate> 
         <Expander Header="{Binding ....}" IsExpanded="True"> 
          <ItemsPresenter /> 
         </Expander> 
        </ControlTemplate> 
       </Setter.Value> 
      </Setter> 
</Style> 


<ListBox x:Name="lbPersonList" Margin="19,17,162,25" AlternationCount="2"> 
      <ListBox.GroupStyle> 
       <GroupStyle ContainerStyle="{StaticResource ContainerStyle}"/> 
      </ListBox.GroupStyle> 
      <ListBox.ItemTemplate> 
       <DataTemplate> 
        <TextBlock Text="{Binding ...}"/> 
       </DataTemplate> 
      </ListBox.ItemTemplate> 
</ListBox> 

의 Nota이 코드를 시도 할 수 있습니다 : 당신은 당신의 코드에 바인딩 조정