Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 848
Alasse Avatar asked Jun 13 '26 15:06

Alasse


1 Answers

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.

like image 131
nemesv Avatar answered Jun 15 '26 10:06

nemesv



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!