Skip to main content

Posts

UWP - How to use ListView item click event

UWP - ListView Item Click Event The ListView class represents a control that displays data items in a vertical stack. The UWP app developers can use ListView to display a collection of items stacked vertically or horizontally. The ListView is an ItemsControl, so the ListView can contain a collection of items of any type. To populate a ListView the UWP developers have to add items to the Items collection or set the ItemsSource property to a data source. The ListView data item is displayed as the string representation by default. The following Universal Windows Platform application development tutorial demonstrates how we can handle the item click event in a LisTview control. In this UWP tutorial code, we put some items into a ListView control using an array item source. We data bind the LisView control programmatically by c# language. Then we add an ItemClick event to the ListView control. We display the ListView clicked item on a dialog when the...

UWP - Horizontal ListView example

UWP - Horizontal ListView The ListView class represents a control that displays data items in a vertical stack in a UWP app. The UWP developers are using a ListView to display a collection of items stacked vertically or horizontally. The ListView is an ItemsControl, so the .net developers can put there a collection of items of any type. The ListView data item is displayed as the string representation by default. The ListView control displays its items vertically. But UWP app developers can display the ListView item collection horizontally. The following app development tutorial code will demonstrate how we can display the ListView data horizontally as a horizontal list. The ItemsControl class’s ItemsPanel property gets or sets the template that defines the panel that controls the layout of items. This property value is an ItemsPanelTemplate instance that defines the panel to use for the layout of the items. The ItemsControl’s default val...

UWP - ListView alternate item style

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" > <ListView x:Name="ListView1" SelectionChanged="ListView1_SelectionChanged" Loaded="ListView1_Loaded" > <ListViewItem>Red</ListViewItem> <ListViewItem>Green</List...

UWP - How to create a ListView programmatically

UWP - Create a ListView programmatically The ListView class represents a control that displays data items in a vertical stack in a UWP app. The UWP app developers are using a ListView to display a collection of items stacked vertically or horizontally. The ListView is an ItemsControl, so the .net developers can put there a collection of items of any type. The ListView data item is displayed as the string representation by default. The developers can define the ListView control’s selection mode for single or multiple. By default, the ListView selection mode is single. They can toggle the mode by using the ListView class SelectionMode property. The ListViewSelectionMode enumeration value allows multi-selection or disabled selection. The ListView() constructor initializes a new instance of the ListView class. The ItemsControl class ItemsSource property gets or sets an object source used to generate the content of the ItemsControl. So using...

UWP - ListView complex ItemsSource example

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="Cornsilk" Padding="50" > <ListView x:Name="ListView1" Header="Choose A Book" SelectionChanged="ListView1_SelectionChanged" > <ListView.ItemTemplate> <DataTemplate> <St...

UWP - ListView Array ItemsSource example

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="PowderBlue" Padding="50" > <ListView x:Name="ListView1" Header="Choose A Color" SelectionChanged="ListView1_SelectionChanged" /> </StackPanel> </Page> MainPage.xaml.cs using Windows.UI.Xaml.Controls; using W...

UWP - How to use ListView

UWP - How to use ListView The ListView class represents a control that displays data items in a vertical stack. The UWP app developers can use ListView to display a collection of items stacked vertically or horizontally. But to display a collection in rows and columns they have to use a GridView. The ListView is an ItemsControl, so the ListView can contain a collection of items of any type. To populate the ListView the UWP developers have to add items to the Items collection or set the ItemsSource property to a data source. The ListView data item is displayed as the string representation by default. But the UWP developers can use DataTemplate and ItemTemplate to customize the ListView items layout. The following Universal Windows Platform application development tutorial demonstrates how we can use a LisTview control. Here we will show the very basic uses of ListView control in a UWP app. In this UWP tutorial code, we put some item...