Blog Posts for: Uwp

Preventing a UWP ListView item to be reordered

10 April 2017

The UWP ListView allows you to easily reorder items inside a ListView by setting the CanReorderItems and AllowDrop properties to True. Let’s for example take a very simple Page with a list view containing 6 buttons. Note that the CanReorderItems and AllowDrop properties are set to True: <Pagex:Class="WorkflowDesigner.MainPage"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:local="using:WorkflowDesigner"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"mc:Ignorable="d"><GridBackground="{ThemeResource ApplicationPageBackgroundThemeBrush}"><ListViewx:Name="ListView1"AllowDrop="True"CanReorderItems="True"><Button>Button 1</Button><Button>Button 2</Button><Button>Button 3</Button><Button>Button 4</Button><Button>Button 5</Button><Button>Button 6</Button></ListView></Grid></Page> When you run the application, you are able to drag any of the items in the list view to a new position inside the list view: