I need to provide my users with the ability to display a vertical list of items in a UWP app. The user should be able to tap items to perform some actions and to reorder them by dragging, but without the ability to select them. The UWP ListView is a good candidate for this. I would use this control with the following settings to implement what I need (a simplified form):
<ListView CanReorderItems="True" AllowDrop="True" SelectionMode="None">
<ListViewItem>Blue</ListViewItem>
<ListViewItem>Red</ListViewItem>
<ListViewItem>Yellow</ListViewItem>
<ListViewItem>Green</ListViewItem>
</ListView>
Sure, in the real app I use data binding through the ItemsSource
property and my custom item template looks like this:
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Rectangle Height="50" Width="50" Fill="RosyBrown" />
<TextBlock Grid.Column="1" Text="Some text" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
Unfortunately, I could not find a good and simple way to do what I need. My main problem is the selection in ListView. For instance, even if I set the ListView's SelectionMode
to None
, the items are still highlighted when the user is moving the mouse pointer over them. The IsHitTestVisible
property also does not help as we can't tap and drag items if we set it to False.
Is there a way to solve my problem?