benruehl / adonis-ui

Lightweight UI toolkit for WPF applications offering classic but enhanced windows visuals
https://benruehl.github.io/adonis-ui/
MIT License
1.71k stars 143 forks source link

ListViewItem defaults to blue-white selection when focusable is disabled #84

Closed micah686 closed 4 years ago

micah686 commented 4 years ago

Describe the bug If you disable the focusable element of the listview, the items you hover over have the default windows blue-white selection bar..

To Reproduce Steps to reproduce the behavior: 1)Add the focusable element to an existing ListView code, as shown below:

<ListView ItemsSource="{Binding GameCollection}" VerticalAlignment="Stretch" MinHeight="150" ScrollViewer.VerticalScrollBarVisibility="Visible">
                    <ListView.ItemContainerStyle>
                        <Style TargetType="ListViewItem">
                            <Setter Property="Focusable" Value="false"/>
                        </Style>
                    </ListView.ItemContainerStyle>
                    <ListView.View>
                        <GridView>
                            <GridViewColumn DisplayMemberBinding="{Binding Path=ExePath}" Header="Exe Path"/>
                            <GridViewColumn DisplayMemberBinding="{Binding Path=IconPath}" Header="Icon Path"/>
                            <GridViewColumn DisplayMemberBinding="{Binding Path=ArgumentsString}" Header="Arguments"/>
                        </GridView>
                    </ListView.View>
                </ListView>

Expected behavior The ListViewItems would not show a change on hover or click

Screenshots If applicable, add screenshots to help explain your problem. image

Additional context Add any other context about the problem here.

rasyidf commented 4 years ago

I've reproduced this bug,

You're replacing the style of Adonis with your own style, which is based on DefaultListViewItem style.

try adding BasedOn="{StaticResource {x:Type ListViewItem}}" , this works for me.

<ListView.ItemContainerStyle>
     <Style TargetType="ListViewItem" BasedOn="{StaticResource {x:Type ListViewItem}}">
          <Setter Property="Focusable" Value="false" />
     </Style>
</ListView.ItemContainerStyle>    
benruehl commented 4 years ago

Thank you for clearing this up @rasyidf.

Indeed, when you use your own style at any point of an application, you have to specify explicitly that it should be derived from the default style of Adonis UI. Unfortunately this is necessary. If the BasedOn statement is missing the style will be based on WPF's default style which has no idea of Adonis UI's theming and thus looks weird.

PS: There is a little typo in the code block at {StaticResource** {x:Type ListViewItem}}. The asterisks have to be removed in order to compile.