Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
XAML ListView
WhatsApp
Mahesh Chand
6y
45.1k
0
5
100
Article
The <ListView> element represents a WPF ListView control in XAML.
<
ListView /
>
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
>
Here is a detailed tutorial on ListView:
WPF ListView Tutorial
.
XAML ListView
ListView Element
Up Next
Ebook Download
View all
Programming XAML
Read by 12.3k people
Download Now!
Learn
View all
Mindcracker
Founded in 2003, Mindcracker is the authority in custom software development and innovation. We put best practices into action. We deliver solutions based on consumer and industry analysis.
Membership not found