Werner
Werner

Reputation: 1311

Disable ListView selection and hover

Usually I can disable ListView selection doing like this thread suggests - or something similar where you set the ItemContainerStyle.

However I have this ListView that is defined like this:

<ScrollViewer>
    <ListView  ItemsSource="{Binding List, Mode=OneWay}">
        <ListView.View>
            <GridView>
                <GridViewColumn>
                    <GridViewColumnHeader Style="{StaticResource header}"/>
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <!-- Some data -->
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                </GridViewColumn>
                ...
            </GridView> 
        </ListView.View>    
    </ListView> 
</ScrollViewer> 

And if I try to specify the ItemContainerStyle - the data in the list just disappears.

Giving the above ListView, how would I proceed just to removed the selection?

Upvotes: 1

Views: 1134

Answers (1)

dhilmathy
dhilmathy

Reputation: 2868

Can you try this ItemContainerStyle? This basically will not pick up any input events.

<ListView ItemsSource="{Binding List, Mode=OneWay}">
    <ListView.ItemContainerStyle>
        <Style TargetType="ListBoxItem" BasedOn="{StaticResource {x:Type ListViewItem}}">
            <Setter Property="IsHitTestVisible" Value="False"/>
        </Style>
    </ListView.ItemContainerStyle>
</ListView>

Upvotes: 3

Related Questions