MainPage.xaml
<Page
x:Class="UniversalAppTutorials.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UniversalAppTutorials"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<StackPanel
x:Name="stack_panel1"
Margin="50"
Orientation="Vertical"
Background="AliceBlue"
Padding="50"
>
<TextBlock
x:Name="TextBlock1"
Foreground="Crimson"
FontFamily="MV Boli"
FontSize="25"
Text="Select item(s) from ListView."
TextWrapping="WrapWholeWords"
Margin="5,5,5,25"
/>
<ListView
x:Name="ListView1"
SelectionChanged="ListView1_SelectionChanged"
SelectionMode="Multiple"
/>
</StackPanel>
</Page>
MainPage.xaml.cs
using Windows.UI.Xaml.Controls;
namespace UniversalAppTutorials
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
// Initialize a new string array
string[] colors = {
"Red",
"Green",
"Blue",
"Yellow",
"Black",
"Gray",
"White",
"Snow",
"Gold"
};
// Specify the list view item source
ListView1.ItemsSource = colors;
}
private void ListView1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
// Get the instance of ListView
ListView listView = sender as ListView;
// Initialize an empty string to store list view selected items
string selectedItems = "";
// Loop through the list view selected items
foreach (string item in listView.SelectedItems)
{
// Add a comma separator
if (selectedItems.Length > 1)
{
selectedItems += ", ";
}
// Add the items to selected items string
selectedItems += item;
};
// Finally, display the list view selected items to text block
TextBlock1.Text = "Selected : " + selectedItems;
}
}
}



- UWP - Segoe MDL2 Assets font example
- UWP - SplitView example
- UWP - SymbolIcon example
- UWP - How to add a new line to a TextBlock
- UWP - PivotItem header with image and text
- UWP - Simple Pivot example
- UWP - Polygon example
- UWP - Rectangle example
- UWP - Get ComboBox selected item
- UWP - ListView ItemTemplate example
- UWP - ListView HeaderTemplate example
- UWP - How to add margin to each item in a ListView
- UWP - How to add item separator to ListView
- UWP - How to use ListView item click event
- UWP - Horizontal ListView example