Export (0) Print
Expand All

ListView.View Property

Gets or sets an object that defines how the data is styled and organized in a ListView control.

Namespace: System.Windows.Controls
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public ViewBase View { get; set; }
/** @property */
public ViewBase get_View ()

/** @property */
public void set_View (ViewBase value)

public function get View () : ViewBase

public function set View (value : ViewBase)

For XAML information, see the ViewBase type.

Property Value

A ViewBase object that specifies how to display information in the ListView.

Identifier field

ViewProperty

Metadata properties set to true

None

The .NET Framework 3.0 environment includes the configurable view mode named GridView. You can also create a custom view that inherits from ViewBase. For more information, see How to: Create a Custom View for a ListView.

The following example shows how to specify a GridView object as the View for a ListView control. For the complete sample, see ListView with Sorting Sample.

<ListView.View>

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

    <GridViewColumn DisplayMemberBinding=
                        "{Binding Path=FirstName}" 
                    Header="First Name" Width="100"/>
    <GridViewColumn DisplayMemberBinding=
                        "{Binding Path=LastName}" 
                    Header="Last Name" Width="100"/>
    <GridViewColumn DisplayMemberBinding=
                        "{Binding Path=EmployeeNumber}" 
                    Header="Employee No." Width="100"/>
  </GridView>

</ListView.View>

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);

More Code

How to: Display ListView Contents by Using a GridView

This example shows how to define a GridView view mode for a ListView control.

How to: Create a Custom View Mode for a ListView

This example shows how to create a custom View mode for a ListView control.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft