There is no ListBox.SelectionMode="None", is there another way to disable selection in a listbox?

How do I disable selection in a ListBox?


Approach 1 - ItemsControl

Unless you need other aspects of the ListBox, you could use ItemsControl instead. It places items in the ItemsPanel and doesn't have the concept of selection.

<ItemsControl ItemsSource="{Binding MyItems}" />

By default, ItemsControl doesn't support virtualization of its child elements. If you have a lot of items, virtualization can reduce memory usage and improve performance, in which case you could use approach 2 and style the ListBox, or add virtualisation to your ItemsControl.

Approach 2 - Styling ListBox

Alternatively, just style the ListBox such that the selection is not visible.

<ListBox.Resources>
  <Style TargetType="ListBoxItem">
    <Style.Resources>
      <!-- SelectedItem with focus -->
      <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}"
                       Color="Transparent" />
      <!-- SelectedItem without focus -->
      <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}"
                       Color="Transparent" />
      <!-- SelectedItem text foreground -->
      <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}"
                       Color="Black" />
    </Style.Resources>
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
  </Style>
</ListBox.Resources>

.net, Could you provide an example where it is valid to have a ListBox that you can not select from? Since the main behavior is to select items. I would probably chose  var selectionMode = listBox.selectionMode; listBox.selectionMode = selectionMode; There are no open issues. There are no closed issues. View on GitHub. Theme


I found a very simple and straight forward solution working for me, I hope it would do for you as well

<ListBox ItemsSource="{Items}">
    <ListBox.ItemContainerStyle>
       <Style TargetType="{x:Type ListBoxItem}">
           <Setter Property="Focusable" Value="False"/>
       </Style>
    </ListBox.ItemContainerStyle>
</ListBox>

ListBox.SelectionMode Property (System.Windows.Forms , There is currently no feedback for this document. Page feedback will appear here​. @Shimmy: It is common for trivial answers to be similar. There is no duplication here worthy of any flag. If you have any more questions about this, please ask on Meta Stack Overflow. – user1228 Jul 7 '11 at 14:42


You could switch to using an ItemsControl instead of a ListBox. An ItemsControl has no concept of selection, so there's nothing to turn off.

ListBox.SelectionMode Property (Windows.UI.Xaml.Controls , ListBox does not work properly when SelectionMode is set to Multiple. ObservableCollection ) and listen to CollectionChanged events on it. There is no ListBox.SelectionMode=“None”, is there another way to disable selection in a listbox? Approach 1 - ItemsControl. Unless you need other aspects of the ListBox, you could use ItemsControl instead. It places items in the ItemsPanel and doesn't have the concept of selection. <ItemsControl ItemsSource = "{Binding MyItems}" />


Another option worth considering is disabling the ListBoxItems. This can be done by setting the ItemContainerStyle as shown in the following snippet.

<ListBox ItemsSource="{Binding YourCollection}">
    <ListBox.ItemContainerStyle>
        <Style TargetType="ListBoxItem">
            <Setter Property="IsEnabled" Value="False" />
        </Style>
    </ListBox.ItemContainerStyle>
</ListBox>

If you don't want the text to be grey you can specify the disabled color by adding a brush to the style's resources with the following key: {x:Static SystemColors.GrayTextBrushKey}. The other solution would be to override the ListBoxItem control template.

ListBox `SelectionMode`=`Multiple` no events · Issue #3497 , However, it's not working. I can still only select one item. By the way, the reason I start with the ListBox selection mode set to single is that as items  Represents a Windows control to display a list of items. The following code example demonstrates how to create a ListBox control that displays multiple items in columns and can have more than one item selected in the control's list. The code for the example adds 50 items to the ListBox using the Add method of the ListBox.ObjectCollection class


This will also work, if I have the need to use listbox instead of itemscontrol, but am just displaying the items which shouldn't be selectable, I use:

<ListBox.ItemContainerStyle>
    <Style TargetType="ListBoxItem">
        <Setter Property="IsHitTestVisible" Value="False" />
    </Style>
</ListBox.ItemContainerStyle>

ListBox SelectionMode, It lets you make a series of items available for selection in a list, with multiple items visible and The options for SelectionMode are Extended (which allows multiple with a ListBox are Count, which returns the number of elements, and Item,  ListBox is an ItemsControl, which means it can contain a collection of objects of any type (such as string, image, or panel). For more information, see the ItemsControl class. More than one item in a ListBox is visible, unlike the ComboBox, which has only the selected item visible unless the IsDropDownOpen property is true. The SelectionMode


The WPF ListBox Control and List Selection Options, The WPF ListBox provides a SelectionMode.Extended; it does not provide '​MultiExtended : I believe that the way that WPF Extended Mode  Is there a WPF control that is a little like a stackpanel (perhaps) that would allow me to bind the contained controls using item templating but without the selection and highlighting?


[Solved] how do I set selectionMode to MultiExtended in .Net4 , The ListBox control enables you to display a list of items to the user that the If you change the selection mode property to multiple select , then you will In Multiple mode , you can select or deselect any item in a ListBox by clicking it. The user can use the keyboard to navigate to columns that are not currently visible. There is no direct way to remove multiple selected items from ListBox when SelectionMode of ListBox is set to "Multiple". So there is a small solution to handle this situation.In following Example ListBox "lstCity" contains multiple cities and SelectionMode is set "Multiple".


C# ListBox Control, ListBox SelectionMode=Single : ListBox « Windows Presentation Foundation « C# / CSharp Tutorial