0

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?

Werner
  • 1,229
  • 1
  • 10
  • 24
  • If there is only one column, and the list should not be selectable, why don't you just use an ItemsControl? – Clemens Jul 27 '18 at 11:53
  • Right my bad in the above example, there are more than one column. But you are probably right that a simple ItemsControl would be more simple/better because there is nothing to select. It is just a list of information.. I'll try that... – Werner Jul 30 '18 at 06:23

1 Answers1

2

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>
dhilmathy
  • 2,800
  • 2
  • 21
  • 29