CollectionViewSource.IsSourceGrouped 속성

정의

원본 데이터가 그룹화되는지 여부를 나타내는 값을 가져오거나 설정합니다.

public:
 property bool IsSourceGrouped { bool get(); void set(bool value); };
bool IsSourceGrouped();

void IsSourceGrouped(bool value);
public bool IsSourceGrouped { get; set; }
var boolean = collectionViewSource.isSourceGrouped;
collectionViewSource.isSourceGrouped = boolean;
Public Property IsSourceGrouped As Boolean
<CollectionViewSource IsSourceGrouped="bool" .../>

속성 값

Boolean

bool

데이터가 그룹화되면 true입니다. 데이터가 그룹화되지 않은 경우 false입니다.

예제

다음 코드 예제에서는 그룹화 LINQ 쿼리의 결과에 ListBox 컨트롤을 바인딩하는 방법을 보여 줍니다. 이 예제에서 팀 컬렉션은 도시별로 그룹화되고 도시 이름과 함께 그룹 머리글로 표시됩니다. 전체 코드 목록은 XAML 데이터 바인딩 샘플을 참조하세요. 그룹화에 대한 추가 예제 코드는 Grouped GridView 샘플을 참조하세요.

<Grid>

  <Grid.Resources>
    <CollectionViewSource x:Name="groupInfoCVS" IsSourceGrouped="true"/>
  </Grid.Resources>

  <ListBox x:Name="lbGroupInfoCVS" 
    ItemsSource="{Binding Source={StaticResource groupInfoCVS}}">

    <ListBox.GroupStyle>
      <GroupStyle>
        <GroupStyle.HeaderTemplate>
          <DataTemplate>

            <TextBlock Text="{Binding Key}"/>

          </DataTemplate>
        </GroupStyle.HeaderTemplate>
      </GroupStyle>
    </ListBox.GroupStyle>

    <ListBox.ItemTemplate>
      <DataTemplate>

        <Border Background="{Binding Color}" 
          Width="200" CornerRadius="10" HorizontalAlignment="Left">

          <TextBlock Text="{Binding Name}" 
            Style="{StaticResource DescriptionTextStyle}" 
            HorizontalAlignment="Center" FontWeight="Bold"/>

        </Border>
      </DataTemplate>
    </ListBox.ItemTemplate>

  </ListBox>

</Grid>
Teams teams = new Teams();
var result = 
    from t in teams 
    group t by t.City into g 
    orderby g.Key 
    select g;
groupInfoCVS.Source = result;

적용 대상

추가 정보