이 설명서는 보관되지만 유지 되지 않습니다.

GridViewRowPresenter 클래스

Represents an object that specifies the layout of a row of data.

네임스페이스: System.Windows.Controls
어셈블리: PresentationFramework(presentationframework.dll)
XML 네임스페이스:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public class GridViewRowPresenter : GridViewRowPresenterBase
public class GridViewRowPresenter extends GridViewRowPresenterBase
public class GridViewRowPresenter extends GridViewRowPresenterBase
<GridViewRowPresenter .../>

The GridViewRowPresenter and GridViewHeaderRowPresenter classes support the GridView view mode for a ListView control.

The following example shows how to use a GridViewRowPresenter to style rows in a ListView control. For the complete sample, see ListView with Styled ListViewItems.

<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
			      xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>

  <StackPanel.Resources>	
    <XmlDataProvider x:Key="MyData" XPath="/Info">
      <x:XData>
        <Info xmlns="">
          <Song Name="Song1" Time="3:54" Artist="Singer1" 
              Rating="3" Disk="Disk1" />
          <Song Name="Song2" Time="4:31" Artist="Singer2" 
              Rating="4" Disk="Disk3"/>
          <Song Name="Song3" Time="5:06" Artist="Singer3" 
              Rating="5" Disk="Disk1" />
          <Song Name="Song4" Time="4:18" Artist="Singer3" 
              Rating="2" Disk="Disk2" />
          <Song Name="Song5" Time="6:15" Artist="Singer1" 
              Rating="5" Disk="Disk3" />
        </Info>
      </x:XData>
    </XmlDataProvider>

    <ControlTemplate x:Key="Default" TargetType='{x:Type ListViewItem}'>
      <StackPanel Background="Beige">
        <GridViewRowPresenter Content="{TemplateBinding Content}"
           Columns="{TemplateBinding GridView.ColumnCollection}"/>
      </StackPanel>
    </ControlTemplate>


    <ControlTemplate x:Key="StronglyRecommended" 
                     TargetType='{x:Type ListViewItem}'>
      <StackPanel Background="Beige">
        <GridViewRowPresenter Content="{TemplateBinding Content}"
           Columns="{TemplateBinding GridView.ColumnCollection}"/>
        <TextBlock Background="LightBlue" Text="Strongly Recommended" />
      </StackPanel>
    </ControlTemplate>

    <ControlTemplate x:Key="Recommended" TargetType='{x:Type ListViewItem}'>
      <StackPanel Background="Beige">
        <GridViewRowPresenter Content="{TemplateBinding Content}"
           Columns="{TemplateBinding GridView.ColumnCollection}"/>
        <TextBlock Background="LightBlue" Text="Recommended" />
      </StackPanel>
    </ControlTemplate>

    <Style x:Key="MyHeaderStyle" TargetType="{x:Type GridViewColumnHeader}">
     <Setter Property="Background" Value="BurlyWood"/>
    </Style>
  </StackPanel.Resources>

  <ListView ItemsSource="{Binding Source={StaticResource MyData}, 
                          XPath=Song}" >

   <ListView.ItemContainerStyle>
    <Style TargetType="{x:Type ListViewItem}"  >
      <Setter Property="Template"
            Value="{StaticResource Default}"/>
      <Style.Triggers>
        <DataTrigger Binding="{Binding XPath=@Rating}" Value="5">
				<Setter Property="Template" 
                Value="{StaticResource StronglyRecommended}"/>
        </DataTrigger>
        <DataTrigger Binding="{Binding XPath=@Rating}" Value="4">
          <Setter Property="Template" 
                Value="{StaticResource Recommended}"/>
        </DataTrigger>
      </Style.Triggers>
	</Style>
  </ListView.ItemContainerStyle>

  <ListView.View>
    <GridView ColumnHeaderContainerStyle="{StaticResource MyHeaderStyle}">
      <GridViewColumn Header="Name" 
                      DisplayMemberBinding="{Binding XPath=@Name}" 
                      Width="100"/>
      <GridViewColumn Header="Time" 
                      DisplayMemberBinding="{Binding XPath=@Time}" 
                      Width="80"/>
      <GridViewColumn Header="Artist"  
                      DisplayMemberBinding="{Binding XPath=@Artist}" 
                      Width="80" />
      <GridViewColumn Header="Disk" 
                      DisplayMemberBinding="{Binding XPath=@Disk}"  
                      Width="100"/>
    </GridView>
  </ListView.View>
  </ListView>

</StackPanel>

추가 코드

How to: Display Data by Using GridViewRowPresenter

This example shows how to use the GridViewRowPresenter and GridViewHeaderRowPresenter objects to display data in columns.

System.Object
   System.Windows.Threading.DispatcherObject
     System.Windows.DependencyObject
       System.Windows.Media.Visual
         System.Windows.UIElement
           System.Windows.FrameworkElement
             System.Windows.Controls.Primitives.GridViewRowPresenterBase
              System.Windows.Controls.GridViewRowPresenter

이 형식의 모든 public static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

Microsoft .NET Framework 3.0은 Windows Vista, Microsoft Windows XP SP2 및 Windows Server 2003 SP1에서 지원됩니다.

.NET Framework

3.0에서 지원
표시: