GroupStyle 클래스

정의

각 수준에서 그룹을 확인하는 방법을 정의합니다.

public ref class GroupStyle : System::ComponentModel::INotifyPropertyChanged
[System.Windows.Localizability(System.Windows.LocalizationCategory.None, Readability=System.Windows.Readability.Unreadable)]
public class GroupStyle : System.ComponentModel.INotifyPropertyChanged
[<System.Windows.Localizability(System.Windows.LocalizationCategory.None, Readability=System.Windows.Readability.Unreadable)>]
type GroupStyle = class
    interface INotifyPropertyChanged
Public Class GroupStyle
Implements INotifyPropertyChanged
상속
GroupStyle
특성
구현

예제

다음 예제에 나온을 ItemsControl 에 바인딩되는 XmlDataProvider 콘텐츠와 코드 숨김 논리를 추가 하 고 그룹화 제거를 포함 하는. 확인란은 확인 하는 경우,의 콘텐츠를 ItemsControl 그룹화 됩니다는 Type 특성입니다.

형식의 각 그룹은 CollectionViewGroup합니다. GroupStyleHeaderTemplate 으로 표시 되도록 지정을 TextBlock 표시 하는 Name 각 그룹입니다. 이 경우에 Name 중 하나는 Work 또는 Home합니다.

<Window x:Class="GroupingSample.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Grouping Sample"
    Width="220" Height="550">
  <StackPanel>

    <StackPanel.Resources>
      <XmlDataProvider x:Key="myTasks" XPath="Tasks/Task">
        <x:XData>
          <Tasks xmlns="">
            <Task Name="Groceries" Priority="2" Type="Home">
              <Description>Pick up Groceries and Detergent</Description>
            </Task>
            <Task Name="Laundry" Priority="2" Type="Home">
              <Description>Do Laundry</Description>
            </Task>
            <Task Name="Email" Priority="1" Type="Work">
              <Description>Email Clients</Description>
            </Task>
            <Task Name="Clean" Priority="3" Type="Work">
              <Description>Clean my office</Description>
            </Task>
            <Task Name="Dinner" Priority="1" Type="Home">
              <Description>Get ready for family reunion</Description>
            </Task>
            <Task Name="Proposals" Priority="2" Type="Work">
              <Description>Review new budget proposals</Description>
            </Task>
          </Tasks>
        </x:XData>
      </XmlDataProvider>
    </StackPanel.Resources>

    <TextBlock Margin="12,5,5,0" FontSize="20" Text="My Task List"/>
    <CheckBox Margin="10,5,5,10" Checked="AddGrouping"
              Unchecked="RemoveGrouping">Group by task type</CheckBox>
    <ItemsControl Margin="10" Name="myItemsControl"
                  ItemsSource="{Binding Source={StaticResource myTasks}}">
      <ItemsControl.ItemTemplate>
        <DataTemplate>
          <DataTemplate.Resources>
            <Style TargetType="TextBlock">
              <Setter Property="FontSize" Value="18"/>
              <Setter Property="HorizontalAlignment" Value="Center"/>
            </Style>
          </DataTemplate.Resources>
          <Grid>
            <Ellipse Fill="Silver"/>
            <StackPanel>
              <TextBlock Margin="3,3,3,0"
                         Text="{Binding XPath=@Name}"/>
              <TextBlock Margin="3,0,3,7"
                         Text="{Binding XPath=@Priority}"/>
            </StackPanel>
          </Grid>
        </DataTemplate>
      </ItemsControl.ItemTemplate>
      <ItemsControl.ItemContainerStyle>
        <Style>
          <Setter Property="Control.Width" Value="100"/>
          <Setter Property="Control.Margin" Value="5"/>
        </Style>
      </ItemsControl.ItemContainerStyle>
      <ItemsControl.GroupStyle>
        <GroupStyle>
          <GroupStyle.HeaderTemplate>
            <DataTemplate>
              <TextBlock FontWeight="Bold" FontSize="15"
                         Text="{Binding Path=Name}"/>
            </DataTemplate>
          </GroupStyle.HeaderTemplate>
        </GroupStyle>
      </ItemsControl.GroupStyle>
    </ItemsControl>
  </StackPanel>
</Window>
using System;
using System.Windows;
using System.Windows.Data;

namespace GroupingSample
{
    public partial class Window1 : System.Windows.Window
    {

        public Window1()
        {
            InitializeComponent();
        }

        CollectionView myView;
        private void AddGrouping(object sender, RoutedEventArgs e)
        {
            myView = (CollectionView)CollectionViewSource.GetDefaultView(myItemsControl.ItemsSource);
            if (myView.CanGroup == true)
            {
                PropertyGroupDescription groupDescription
                    = new PropertyGroupDescription("@Type");
                myView.GroupDescriptions.Add(groupDescription);
            }
            else
            {
                return;
            }
        }

        private void RemoveGrouping(object sender, RoutedEventArgs e)
        {
            myView = (CollectionView)CollectionViewSource.GetDefaultView(myItemsControl.ItemsSource);
            myView.GroupDescriptions.Clear();
        }
    }
}

Imports System.Windows
Imports System.Windows.Data

Namespace GroupingSample
    Partial Public Class Window1
        Inherits System.Windows.Window

        Public Sub New()
            InitializeComponent()
        End Sub

        Private myView As CollectionView
        Private Sub AddGrouping(ByVal sender As Object, ByVal e As RoutedEventArgs)
            myView = CType(CollectionViewSource.GetDefaultView(myItemsControl.ItemsSource), CollectionView)
            If myView.CanGroup = True Then
                Dim groupDescription As New PropertyGroupDescription("@Type")
                myView.GroupDescriptions.Add(groupDescription)
            Else
                Return
            End If
        End Sub

        Private Sub RemoveGrouping(ByVal sender As Object, ByVal e As RoutedEventArgs)
            myView = CType(CollectionViewSource.GetDefaultView(myItemsControl.ItemsSource), CollectionView)
            myView.GroupDescriptions.Clear()
        End Sub
    End Class
End Namespace

생성자

GroupStyle()

GroupStyle 클래스의 새 인스턴스를 초기화합니다.

필드

DefaultGroupPanel

항목의 레이아웃에 사용되는 패널을 만드는 기본 ItemsPanelTemplate을 식별합니다.

속성

AlternationCount

교대로 반복되는 GroupItem 개체의 수를 가져오거나 설정합니다.

ContainerStyle

각 항목에 대해 생성된 GroupItem에 적용되는 스타일을 가져오거나 설정합니다.

ContainerStyleSelector

애플리케이션 작성자가 스타일에 대한 사용자 지정 선택 논리를 제공하여 생성된 각 GroupItem에 적용할 수 있도록 합니다.

Default

그룹의 기본 스타일을 가져옵니다.

HeaderStringFormat

헤더가 문자열로 표시되는 경우 헤더의 형식을 지정하는 방법을 지정하는 합성 문자열을 가져오거나 설정합니다.

HeaderTemplate

그룹 머리글을 표시하는 데 사용되는 템플릿을 가져오거나 설정합니다.

HeaderTemplateSelector

애플리케이션 작성자가 그룹 머리글을 표시하는 데 사용되는 템플릿에 대한 사용자 지정 선택 논리를 제공할 수 있도록 합니다.

HidesIfEmpty

빈 그룹에 해당하는 항목을 표시해야 하는지 여부를 나타내는 값을 가져오거나 설정합니다.

Panel

항목의 레이아웃에 사용되는 패널을 만드는 템플릿을 가져오거나 설정합니다.

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
OnPropertyChanged(PropertyChangedEventArgs)

지정된 인수를 사용하여 PropertyChanged 이벤트를 발생시킵니다.

ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

이벤트

PropertyChanged

속성 값이 변경될 때 발생합니다.

명시적 인터페이스 구현

INotifyPropertyChanged.PropertyChanged

속성 값이 변경될 때 발생합니다.

적용 대상

추가 정보