Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Per Martin Konicek's comment, to fully disable the selection of the items in the simplest manner:</p> <pre><code>&lt;ListView&gt; &lt;ListView.ItemContainerStyle&gt; &lt;Style TargetType="ListViewItem"&gt; &lt;Setter Property="Focusable" Value="false"/&gt; &lt;/Style&gt; &lt;/ListView.ItemContainerStyle&gt; ... &lt;/ListView&gt; </code></pre> <p>However if you still require the functionality of the ListView, like being able to select an item, then you can visually disable the styling of the selected item like so:</p> <p>You can do this a number of ways, from changing the ListViewItem's <a href="http://msdn.microsoft.com/en-us/library/ms788717.aspx" rel="noreferrer">ControlTemplate</a> to just setting a style (much easier). You can create a style for the ListViewItems using the <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.itemscontrol.itemcontainerstyle.aspx" rel="noreferrer">ItemContainerStyle</a> and 'turn off' the background and border brush when it is selected.</p> <pre><code>&lt;ListView&gt; &lt;ListView.ItemContainerStyle&gt; &lt;Style TargetType="{x:Type ListViewItem}"&gt; &lt;Style.Triggers&gt; &lt;Trigger Property="IsSelected" Value="True"&gt; &lt;Setter Property="Background" Value="{x:Null}" /&gt; &lt;Setter Property="BorderBrush" Value="{x:Null}" /&gt; &lt;/Trigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; &lt;/ListView.ItemContainerStyle&gt; ... &lt;/ListView&gt; </code></pre> <p>Also, unless you have some other way of notifying the user when the item is selected (or just for testing) you can add a column to represent the value:</p> <pre><code>&lt;GridViewColumn Header="IsSelected" DisplayMemberBinding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListViewItem}}, Path=IsSelected}" /&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload