The <ListView> element represents a WPF ListView control in XAML.
The code example in the following list creates a ListView and sets its properties.
- <ListView Margin="10,10,0,13" Name="ListView1" HorizontalAlignment="Left"
- VerticalAlignment="Top" Width="200" Height="300" />
The ListViewItem item represents an item of ListView. The following code example adds several items to a ListView.
- <ListView Margin="10,10,0,13" Name="ListView1" HorizontalAlignment="Left"
- VerticalAlignment="Top" Width="194" Height="200">
- <ListViewItem Content="Coffie"></ListViewItem>
- <ListViewItem Content="Tea"></ListViewItem>
- <ListViewItem Content="Orange Juice"></ListViewItem>
- <ListViewItem Content="Milk"></ListViewItem>
- <ListViewItem Content="Iced Tea"></ListViewItem>
- <ListViewItem Content="Mango Shake"></ListViewItem>
- </ListView>
The Foreground and Background attributes of a ListViewItem represents the background and foreground colors of the item. The following code snippet sets the background and foreground colors of a ListViewItem.
- <ListViewItem Background="LightCoral" Foreground="Red" Content="Coffie"></ListViewItem>
The FontFamily, FontSize and FontWeight are used to set a font of a ListViewItem. The following code snippet sets font verdana, size 12 and bold of a ListViewItem.
- <ListViewItem Background="LightCoral" Foreground="Red" Content="Coffie"
- FontFamily="Verdana" FontSize="12" FontWeight="Bold"></ListViewItem>
- I set the following properties of ListViewItems.
- <ListViewItem Background="LightCoral" Foreground="Red" Content="Coffie"
- FontFamily="Verdana" FontSize="12" FontWeight="Bold"></ListViewItem>
- <ListViewItem Background="LightGray" Foreground="Black" Content="Tea"
- FontFamily="Georgia" FontSize="14" FontWeight="Bold"></ListViewItem>
- <ListViewItem Background="LightBlue" Foreground="Purple" Content="Orange Juice"
- FontFamily="Verdana" FontSize="12" FontWeight="Bold"></ListViewItem>
- <ListViewItem Background="LightGreen" Foreground="Green" Content="Milk"
- FontFamily="Georgia" FontSize="14" FontWeight="Bold"></ListViewItem>
- <ListViewItem Background="LightBlue" Foreground="Blue" Content="Iced Tea"
- FontFamily="Verdana" FontSize="12" FontWeight="Bold"></ListViewItem>
- <ListViewItem Background="LightSlateGray" Foreground="Orange" Content="Mango Shake"
- FontFamily="Georgia" FontSize="14" FontWeight="Bold"></ListViewItem>