0

So I have this scrollbar style to make the scrollbar look a bit better than the default one.

And when my ListView uses it, it looks great, until both scrollbars become visible, because then it starts showing a white rectangle at the bottom right where the scrollbars meet.

enter image description here

How do I properly get rid of it? Or at least change color.

ListView.xaml

<ListView Grid.Column="1"
          ItemsSource="{Binding Properties}"
          Background="{StaticResource SecondaryDark}"
          BorderThickness="0"
          HorizontalContentAlignment="Stretch"
          ScrollViewer.CanContentScroll="False">

            

            <ListView.ItemTemplate>
                <DataTemplate>
                    <Grid Margin="5">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="200" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <TextBlock Grid.Column="0" Text="{Binding Name}"
                                   VerticalAlignment="Center"
                                   Foreground="{StaticResource OffWhite}"
                                   FontFamily="/CacheTool;component/Fonts/#Fira Code"
                                   FontWeight="SemiBold" />

                        <ContentControl Grid.Column="1"
                                        Content="{Binding}"
                                        ContentTemplateSelector="{StaticResource PropertyControlTemplateSelector}" />
                    </Grid>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>

Style.xaml

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:system="clr-namespace:System;assembly=System.Runtime">
    <system:Double x:Key="ScrollBarWidth">16</system:Double>
    <system:Double x:Key="ScrollBarArrowHeight">4</system:Double>
    <system:Double x:Key="ScrollBarArrowWidth">8</system:Double>

    <SolidColorBrush x:Key="ScrollBarButtonBackgroundBrush" Color="#303030" />
    <SolidColorBrush x:Key="ScrollBarButtonHighlightBackgroundBrush" Color="#404040" />
    <SolidColorBrush x:Key="ScrollBarButtonArrowForegroundBrush" Color="#555555" />
    <SolidColorBrush x:Key="ScrollBarTrackBrush" Color="#252525" />

    <Style TargetType="{x:Type ScrollBar}">
        <Style.Triggers>
            <Trigger Property="Orientation" Value="Vertical">
                <Setter Property="Width" Value="{StaticResource ScrollBarWidth}" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ScrollBar}">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="*" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>

                                <Button Grid.Row="0"
                                        Command="ScrollBar.LineUpCommand"
                                        Height="{StaticResource ScrollBarWidth}">
                                    <Button.Template>
                                        <ControlTemplate TargetType="Button">
                                            <Grid>
                                                <Rectangle x:Name="ButtonRectangle"
                                                           Fill="{StaticResource ScrollBarButtonBackgroundBrush}" />
                                                <Path HorizontalAlignment="Center"
                                                      VerticalAlignment="Center"
                                                      Data="M 0 10 L 10 10 L 5 0 Z"
                                                      Fill="{StaticResource ScrollBarButtonArrowForegroundBrush}"
                                                      Stretch="Fill"
                                                      Height="{StaticResource ScrollBarArrowHeight}"
                                                      Width="{StaticResource ScrollBarArrowWidth}" />
                                            </Grid>
                                            <ControlTemplate.Triggers>
                                                <Trigger Property="IsMouseOver" Value="True">
                                                    <Setter TargetName="ButtonRectangle" Property="Fill"
                                                            Value="{StaticResource ScrollBarButtonHighlightBackgroundBrush}" />
                                                </Trigger>
                                            </ControlTemplate.Triggers>
                                        </ControlTemplate>
                                    </Button.Template>
                                </Button>

                                <Track Name="PART_Track" IsDirectionReversed="True" VerticalAlignment="Stretch"
                                       Grid.Row="1">
                                    <Track.DecreaseRepeatButton>
                                        <RepeatButton Command="ScrollBar.PageUpCommand"
                                                      Background="{StaticResource ScrollBarTrackBrush}">
                                            <RepeatButton.Template>
                                                <ControlTemplate TargetType="RepeatButton">
                                                    <Rectangle Fill="{TemplateBinding Background}"
                                                               Height="{TemplateBinding ActualHeight}"
                                                               Width="{TemplateBinding ActualWidth}" />
                                                </ControlTemplate>
                                            </RepeatButton.Template>
                                        </RepeatButton>
                                    </Track.DecreaseRepeatButton>

                                    <Track.Thumb>
                                        <Thumb>
                                            <Thumb.Template>
                                                <ControlTemplate TargetType="Thumb">
                                                    <Rectangle x:Name="ThumbRectangle"
                                                               Fill="{StaticResource ScrollBarButtonBackgroundBrush}" />
                                                    <ControlTemplate.Triggers>
                                                        <Trigger Property="IsMouseOver" Value="True">
                                                            <Setter TargetName="ThumbRectangle" Property="Fill"
                                                                    Value="{StaticResource ScrollBarButtonHighlightBackgroundBrush}" />
                                                        </Trigger>
                                                    </ControlTemplate.Triggers>
                                                </ControlTemplate>
                                            </Thumb.Template>
                                        </Thumb>
                                    </Track.Thumb>

                                    <Track.IncreaseRepeatButton>
                                        <RepeatButton Command="ScrollBar.PageDownCommand"
                                                      Background="{StaticResource ScrollBarTrackBrush}">
                                            <RepeatButton.Template>
                                                <ControlTemplate TargetType="RepeatButton">
                                                    <Rectangle Fill="{TemplateBinding Background}"
                                                               Height="{TemplateBinding ActualHeight}"
                                                               Width="{TemplateBinding ActualWidth}" />
                                                </ControlTemplate>
                                            </RepeatButton.Template>
                                        </RepeatButton>
                                    </Track.IncreaseRepeatButton>
                                </Track>


                                <Button Grid.Row="2"
                                        Command="ScrollBar.LineDownCommand"
                                        Height="{StaticResource ScrollBarWidth}">
                                    <Button.Template>
                                        <ControlTemplate TargetType="Button">
                                            <Grid>
                                                <Rectangle x:Name="ButtonRectangle"
                                                           Fill="{StaticResource ScrollBarButtonBackgroundBrush}" />
                                                <Path HorizontalAlignment="Center"
                                                      VerticalAlignment="Center"
                                                      Data="M 0 0 L 10 0 L 5 10 Z"
                                                      Fill="{StaticResource ScrollBarButtonArrowForegroundBrush}"
                                                      Stretch="Fill"
                                                      Height="{StaticResource ScrollBarArrowHeight}"
                                                      Width="{StaticResource ScrollBarArrowWidth}" />
                                            </Grid>
                                            <ControlTemplate.Triggers>
                                                <Trigger Property="IsMouseOver" Value="True">
                                                    <Setter TargetName="ButtonRectangle" Property="Fill"
                                                            Value="{StaticResource ScrollBarButtonHighlightBackgroundBrush}" />
                                                </Trigger>
                                            </ControlTemplate.Triggers>
                                        </ControlTemplate>
                                    </Button.Template>
                                </Button>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Trigger>
            <Trigger Property="Orientation" Value="Horizontal">
                <Setter Property="Height" Value="{StaticResource ScrollBarWidth}" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ScrollBar}">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>

                                <Button Grid.Column="0"
                                        Command="ScrollBar.LineLeftCommand"
                                        Width="{StaticResource ScrollBarWidth}">
                                    <Button.Template>
                                        <ControlTemplate TargetType="Button">
                                            <Grid>
                                                <Rectangle x:Name="ButtonRectangle"
                                                           Fill="{StaticResource ScrollBarButtonBackgroundBrush}" />
                                                <Path HorizontalAlignment="Center"
                                                      VerticalAlignment="Center"
                                                      Data="M 0 5 L 10 0 L 10 10 Z"
                                                      Fill="{StaticResource ScrollBarButtonArrowForegroundBrush}"
                                                      Stretch="Fill"
                                                      Height="{StaticResource ScrollBarArrowWidth}"
                                                      Width="{StaticResource ScrollBarArrowHeight}" />
                                            </Grid>
                                            <ControlTemplate.Triggers>
                                                <Trigger Property="IsMouseOver" Value="True">
                                                    <Setter TargetName="ButtonRectangle" Property="Fill"
                                                            Value="{StaticResource ScrollBarButtonHighlightBackgroundBrush}" />
                                                </Trigger>
                                            </ControlTemplate.Triggers>
                                        </ControlTemplate>
                                    </Button.Template>
                                </Button>

                                <Track Name="PART_Track" IsDirectionReversed="False" HorizontalAlignment="Stretch"
                                       Grid.Column="1">
                                    <Track.DecreaseRepeatButton>
                                        <RepeatButton Command="ScrollBar.PageLeftCommand"
                                                      Background="{StaticResource ScrollBarTrackBrush}">
                                            <RepeatButton.Template>
                                                <ControlTemplate TargetType="RepeatButton">
                                                    <Rectangle Fill="{TemplateBinding Background}"
                                                               Height="{TemplateBinding ActualHeight}"
                                                               Width="{TemplateBinding ActualWidth}" />
                                                </ControlTemplate>
                                            </RepeatButton.Template>
                                        </RepeatButton>
                                    </Track.DecreaseRepeatButton>

                                    <Track.Thumb>
                                        <Thumb>
                                            <Thumb.Template>
                                                <ControlTemplate TargetType="Thumb">
                                                    <Rectangle x:Name="ThumbRectangle"
                                                               Fill="{StaticResource ScrollBarButtonBackgroundBrush}" />
                                                    <ControlTemplate.Triggers>
                                                        <Trigger Property="IsMouseOver" Value="True">
                                                            <Setter TargetName="ThumbRectangle" Property="Fill"
                                                                    Value="{StaticResource ScrollBarButtonHighlightBackgroundBrush}" />
                                                        </Trigger>
                                                    </ControlTemplate.Triggers>
                                                </ControlTemplate>
                                            </Thumb.Template>
                                        </Thumb>
                                    </Track.Thumb>

                                    <Track.IncreaseRepeatButton>
                                        <RepeatButton Command="ScrollBar.PageRightCommand"
                                                      Background="{StaticResource ScrollBarTrackBrush}">
                                            <RepeatButton.Template>
                                                <ControlTemplate TargetType="RepeatButton">
                                                    <Rectangle Fill="{TemplateBinding Background}"
                                                               Height="{TemplateBinding ActualHeight}"
                                                               Width="{TemplateBinding ActualWidth}" />
                                                </ControlTemplate>
                                            </RepeatButton.Template>
                                        </RepeatButton>
                                    </Track.IncreaseRepeatButton>
                                </Track>


                                <Button Grid.Column="2"
                                        Command="ScrollBar.LineRightCommand"
                                        Width="{StaticResource ScrollBarWidth}">
                                    <Button.Template>
                                        <ControlTemplate TargetType="Button">
                                            <Grid>
                                                <Rectangle x:Name="ButtonRectangle"
                                                           Fill="{StaticResource ScrollBarButtonBackgroundBrush}" />
                                                <Path HorizontalAlignment="Center"
                                                      VerticalAlignment="Center"
                                                      Data="M 10 5 L 0 0 L 0 10 Z"
                                                      Fill="{StaticResource ScrollBarButtonArrowForegroundBrush}"
                                                      Stretch="Fill"
                                                      Height="{StaticResource ScrollBarArrowWidth}"
                                                      Width="{StaticResource ScrollBarArrowHeight}" />
                                            </Grid>
                                            <ControlTemplate.Triggers>
                                                <Trigger Property="IsMouseOver" Value="True">
                                                    <Setter TargetName="ButtonRectangle" Property="Fill"
                                                            Value="{StaticResource ScrollBarButtonHighlightBackgroundBrush}" />
                                                </Trigger>
                                            </ControlTemplate.Triggers>
                                        </ControlTemplate>
                                    </Button.Template>
                                </Button>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Trigger>
        </Style.Triggers>
    </Style>
    
    
</ResourceDictionary>
3
  • 1
    This question is similar to: ScrollViewer WPF bottom right corner color. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. Commented Sep 24 at 11:07
  • One way is to style vertical scroll bar to take up all of the available space and the horizontal one to stay as it is. That's from my own experience, least headache 😅 Commented Sep 27 at 0:29
  • unfortunately, seems like you need to overwrite the template of entire ListView, there inside will be a scrollView which could be styled by you. Commented Oct 6 at 5:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.