Note that there are some explanatory texts on larger screens.

plurals
  1. POListview selection color
    primarykey
    data
    text
    <p>I'm playing around with wpf and I saw the following article: <a href="https://stackoverflow.com/questions/382006/wpf-listview-inactive-selection-color">WPF ListView Inactive Selection Color</a></p> <p>I want to do something similar. I want to put a border around an a listviewitem when it is selected and i want to not change the background color. The reason I want this is I want a color coded listview and I still want to see the color when it's selected, but i want to know it's selected by it having a border around it.</p> <p>Any ideas?</p> <p><strong>UPDATE:</strong></p> <p>I tried the below answer and it got me half way, it does put a border around the listviewitem but it overrides my background color. I can't get the right syntax i tried(Notice the BasedOn):</p> <pre><code> &lt;Style x:Key="SourceListView" TargetType="{x:Type ListViewItem}"&gt; &lt;Setter Property="Background" Value="{Binding SourceType, Converter={StaticResource SourceGroupConverter}}"/&gt; &lt;/Style&gt; &lt;Style x:Key="MyListViewItemStyle" TargetType="{x:Type ListViewItem}" BasedOn="{StaticResource SourceListView}" &gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type ListViewItem}"&gt; &lt;Border x:Name="Border" BorderBrush="Transparent" BorderThickness="1"&gt; &lt;GridViewRowPresenter Columns="{TemplateBinding GridView.ColumnCollection}" Content="{TemplateBinding Content}"/&gt; &lt;/Border&gt; &lt;ControlTemplate.Triggers&gt; &lt;Trigger Property="IsSelected" Value="true"&gt; &lt;Setter TargetName="Border" Property="BorderBrush" Value="Black"/&gt; &lt;/Trigger&gt; &lt;/ControlTemplate.Triggers&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>I then tried this:</p> <pre><code> &lt;Style x:Key="MyListViewItemStyle" TargetType="{x:Type ListViewItem}"&gt; &lt;Setter Property="Background" Value="{Binding SourceType, Converter={StaticResource SourceGroupConverter}}"/&gt; &lt;Setter Property="Template"&gt; ...//Same as above &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>Both attempts just set the background to white(or transparent I don't know). I know it's just syntax and I'd appreciate another nudge in the right direction :)</p>
    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.
 

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