ListView.View プロパティ

定義

ListView コントロール内のデータのスタイル設定および構成を定義するオブジェクトを取得または設定します。Gets or sets an object that defines how the data is styled and organized in a ListView control.

public:
 property System::Windows::Controls::ViewBase ^ View { System::Windows::Controls::ViewBase ^ get(); void set(System::Windows::Controls::ViewBase ^ value); };
public System.Windows.Controls.ViewBase View { get; set; }
member this.View : System.Windows.Controls.ViewBase with get, set
Public Property View As ViewBase

プロパティ値

ViewBase

ViewBase 内の情報の表示方法を指定する ListViewオブジェクト。A ViewBase object that specifies how to display information in the ListView.

次の例は、コントロールのとしてオブジェクトを指定する方法を示して GridView View ListView います。The following example shows how to specify a GridView object as the View for a ListView control.

ListView myListView = new ListView();

GridView myGridView = new GridView();
myGridView.AllowsColumnReorder = true; 
myGridView.ColumnHeaderToolTip = "Employee Information";

GridViewColumn gvc1 = new GridViewColumn();
gvc1.DisplayMemberBinding = new Binding("FirstName");
gvc1.Header = "FirstName";
gvc1.Width = 100;
myGridView.Columns.Add(gvc1);
GridViewColumn gvc2 = new GridViewColumn();
gvc2.DisplayMemberBinding = new Binding("LastName");
gvc2.Header = "Last Name";
gvc2.Width = 100;
myGridView.Columns.Add(gvc2);
GridViewColumn gvc3 = new GridViewColumn();
gvc3.DisplayMemberBinding = new Binding("EmployeeNumber");
gvc3.Header = "Employee No.";
gvc3.Width = 100;
myGridView.Columns.Add(gvc3);

//ItemsSource is ObservableCollection of EmployeeInfo objects
myListView.ItemsSource = new myEmployees();
myListView.View = myGridView;
myStackPanel.Children.Add(myListView);
Dim myListView As New ListView()

Dim myGridView As New GridView()
myGridView.AllowsColumnReorder = True
myGridView.ColumnHeaderToolTip = "Employee Information"

Dim gvc1 As New GridViewColumn()
gvc1.DisplayMemberBinding = New Binding("FirstName")
gvc1.Header = "FirstName"
gvc1.Width = 100
myGridView.Columns.Add(gvc1)
Dim gvc2 As New GridViewColumn()
gvc2.DisplayMemberBinding = New Binding("LastName")
gvc2.Header = "Last Name"
gvc2.Width = 100
myGridView.Columns.Add(gvc2)
Dim gvc3 As New GridViewColumn()
gvc3.DisplayMemberBinding = New Binding("EmployeeNumber")
gvc3.Header = "Employee No."
gvc3.Width = 100
myGridView.Columns.Add(gvc3)

'ItemsSource is ObservableCollection of EmployeeInfo objects
myListView.ItemsSource = New myEmployees()
myListView.View = myGridView
myStackPanel.Children.Add(myListView)
<ListView.View>

  <GridView AllowsColumnReorder="true"
            ColumnHeaderToolTip="Employee Information">

    <GridViewColumn DisplayMemberBinding=
                        "{Binding Path=FirstName}" 
                    Header="First Name" Width="100"/>
      
                <GridViewColumn DisplayMemberBinding=
                        "{Binding Path=LastName}" 
                    Width="100">
                    <GridViewColumnHeader>Last Name
                        <GridViewColumnHeader.ContextMenu>
                        <ContextMenu  MenuItem.Click="LastNameCM_Click"  
                                      Name="LastNameCM">
                            <MenuItem Header="Ascending" />
                            <MenuItem Header="Descending" />
                        </ContextMenu>
                        </GridViewColumnHeader.ContextMenu>
                    </GridViewColumnHeader>
                </GridViewColumn>

                <GridViewColumn DisplayMemberBinding=
                        "{Binding Path=EmployeeNumber}" 
                    Header="Employee No." Width="100"/>
  </GridView>

</ListView.View>

注釈

.NET Framework 環境には、という名前の構成可能なビューモードが含まれてい GridView ます。The .NET Framework environment includes the configurable view mode named GridView. また、から継承するカスタムビューを作成することもでき ViewBase ます。You can also create a custom view that inherits from ViewBase. 詳細については、「 方法: ListView のカスタムビューモードを作成する」を参照してください。For more information, see How to: Create a Custom View Mode for a ListView.

依存プロパティ情報Dependency Property Information

識別子フィールドIdentifier field ViewProperty
メタデータプロパティがに設定される trueMetadata properties set to true なしNone

注意

このプロパティのプロパティメタデータの型は PropertyMetadata であり、ではありません FrameworkPropertyMetadataThe type of property metadata for this property is PropertyMetadata, not FrameworkPropertyMetadata.

適用対象

こちらもご覧ください