Pages

Tuesday, 12 March 2013

ListView Control Using WPF Window Based

ListView Control Using WPF Window Based

The ListView tag represents a WPF ListView control in XAML.

<ListView></ListView>

The Width and Height properties represent the width and the height of a ListView. The Name property represents the name of the control, which is a unique identifier of a control. The Margin property tells the location of a ListView on the parent control. The HorizontalAlignment and VerticalAlignment properties are used to set horizontal and vertical alignments.

The following code snippet sets the name, height, and width of a ListView control. The code also sets horizontal alignment to left and vertical alignment to top.

Syntax:

 
<ListView Margin="10,10,0,13" Name="ListView1" HorizontalAlignment="Left"
                 VerticalAlignment="Top" Width="194" Height="200" />


Adding ListView Items:

A ListView control hosts a collection of ListViewItem. The following code snippet adds items to a ListView control.

XAML CODE:


 <ListView Margin="35,40,0,97" Name="ListView1" HorizontalAlignment="Left" Width="183">
            <ListViewItem Content="C"></ListViewItem>
            <ListViewItem Content="C++"></ListViewItem>
            <ListViewItem Content="Java"></ListViewItem>
            <ListViewItem Content=".Net"></ListViewItem>
            <ListViewItem Content="Oracle"></ListViewItem>
            <ListViewItem Content="SilverLight"></ListViewItem>
            <ListViewItem Content="SharePoint"></ListViewItem>
            <ListViewItem Content="WPF"></ListViewItem>
            <ListViewItem Content="WCF"></ListViewItem>
        </ListView> 
 
Output

No comments:

Post a Comment