xamlwindows-store-apps

Listview Disabling item click


I am developing Windows Store App, and I have such XAML code:

<Popup x:Name="Panel3" IsOpen="False" Grid.ColumnSpan="18" Grid.Column="13" Grid.Row="4" Grid.RowSpan="31">
    <StackPanel>
        <Rectangle  Width="765" Height="10" />
        <ListView x:Name="Person" Grid.ColumnSpan="18" Grid.Column="13" HorizontalAlignment="Left" Height="643" Grid.Row="4" Grid.RowSpan="31" VerticalAlignment="Top" Width="765" >
            <ListView.Background>
                <SolidColorBrush Color="#FF665920" Opacity="0.85"/>
            </ListView.Background>
            <ListView.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding name}"/>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </StackPanel>
</Popup>

I want to make item selection on listview disabled. So it is for view only, users cannot select/click anything inside listview. How can i make that happen? My regards...

P.S. I added IsItemClickEnabled="False" to listview line:

<ListView x:Name="Person" Grid.ColumnSpan="18" Grid.Column="13" HorizontalAlignment="Left" Height="643" Grid.Row="4" Grid.RowSpan="31" VerticalAlignment="Top" Width="765" IsItemClickEnabled="False">

But it did not change anything, still clickable.


Solution

  • You need set the SelectionMode property to None to disable the item selection of a ListView:

    <ListView x:Name="Person" SelectionMode="None" ... />
    

    additionally you may still need the IsItemClickEnabled="False" depending on your needs.