Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9119205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:20:26+00:00 2026-06-17T05:20:26+00:00

I have created a custom scrollbar template (for a WPF 4 project) for styling

  • 0

I have created a custom scrollbar template (for a WPF 4 project) for styling all the scroll bars in my project. The problem I am having is that I have set my scrollbar thumb to a rectangle object and now the virtualization(re-sizing of the thumb based on the number of records in the listbox) no longer works and the rectangle gets cut off if I try to set an explicit height.

Here is the xaml I used to create the custom template.

<!-- CUSTOM SCROLL BAR ELEMENTS -->
<Style x:Key="ScrollBarLineButtonStyleUp" TargetType="{x:Type RepeatButton}">
    <Setter Property="Focusable" Value="False"/>
    <Setter Property="Margin" Value="1,0,1,4" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type RepeatButton}">
                <Grid Margin="1">
                    <Path Name="UpButton" Fill="{StaticResource ScrollBarGray}" Data="M 0 6 L 12 6 L 6 0 Z"/>
                </Grid>
                <ControlTemplate.Triggers>
                    <Trigger Property="IsPressed" Value="true">
                        <Setter TargetName="UpButton" Property="Fill" Value="{StaticResource SelectedGray}" />
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

<Style x:Key="ScrollBarLineButtonStyleDown" TargetType="{x:Type RepeatButton}">
    <Setter Property="Focusable" Value="False"/>
    <Setter Property="Margin" Value="1,4,1,0" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type RepeatButton}">
                <Grid Margin="1">
                    <Path Name="UpButton" Fill="{StaticResource ScrollBarGray}" Data="M 0 0 L 6 6 L 12 0 Z"/>
                </Grid>
                <ControlTemplate.Triggers>
                    <Trigger Property="IsPressed" Value="true">
                        <Setter TargetName="UpButton" Property="Fill" Value="{StaticResource SelectedGray}" />
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

<Style x:Key="ScrollBarPageButtonStyle" TargetType="{x:Type RepeatButton}">
    <Setter Property="IsTabStop" Value="False"/>
    <Setter Property="Focusable" Value="False"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type RepeatButton}">
                <Border Background="Transparent" />
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

<Style x:Key="ScrollBarThumbStyle" TargetType="{x:Type Thumb}">
    <Setter Property="IsTabStop" Value="False"/>
    <Setter Property="Focusable" Value="False"/>
    <Setter Property="Margin" Value="3,0,4,0" />

    <Setter Property="Background" Value="{x:Null}" />
    <Setter Property="BorderBrush" Value="{x:Null}" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type Thumb}">
                <Rectangle Fill="{StaticResource ScrollBarGray}" RadiusX="4" RadiusY="4" Width="8" />
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

<Style x:Key="stuff" TargetType="{x:Type ScrollBar}">
    <Setter Property="ViewportSize" Value="10"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type ScrollBar}">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition MaxHeight="14"/>
                        <RowDefinition Height="*"/>
                        <RowDefinition MaxHeight="14"/>
                    </Grid.RowDefinitions>
                    <RepeatButton Grid.Row="0" Style="{StaticResource ScrollBarLineButtonStyleUp}" Command="ScrollBar.LineUpCommand" />
                    <Track Name="PART_Track" Grid.Row="1" IsDirectionReversed="True" ViewportSize="0">
                        <Track.DecreaseRepeatButton>
                            <RepeatButton Command="ScrollBar.PageUpCommand" Style="{StaticResource ScrollBarPageButtonStyle}"/>
                        </Track.DecreaseRepeatButton>
                        <Track.Thumb>
                            <Thumb Style="{StaticResource ScrollBarThumbStyle}"/>
                        </Track.Thumb>
                        <Track.IncreaseRepeatButton>
                            <RepeatButton Command="ScrollBar.PageDownCommand" Style="{StaticResource ScrollBarPageButtonStyle}"/>
                        </Track.IncreaseRepeatButton>
                    </Track>
                    <RepeatButton Grid.Row="3"  Style="{StaticResource ScrollBarLineButtonStyleDown}" Command="ScrollBar.LineDownCommand"/>
                </Grid>
            </ControlTemplate>
        </Setter.Value> 
    </Setter> 

</Style> 

I would greatly appreciate if anyone could help me restore the virtualization of my scrollbar thumb

JK

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T05:20:27+00:00Added an answer on June 17, 2026 at 5:20 am

    Never did find the answer, so I used another template that was provided through codeproject and customized it to what I wanted. The following is the article I used as the base for my new scrollbar. I would also included an image of the finished product scrollbar but I don’t have enough reputation points.

    http://www.codeproject.com/Articles/41787/Creating-a-Blend-like-Scrollbar

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a custom method that will return unique items, together with the
I have created a custom scroll. In which I am shifting the contents right
I have created custom dialog that located in values/styles: <style name=AppTheme parent=android:Theme.Light /> <style
Have created a custom navigation menu in wordpress that has some pages and some
I have created a custom control that simply draws a grid of squares on
I have created custom post types that also have custom meta_boxes I've created. Currently,
i have created custom camera overlay view from this blog AROVerlayViewController it's all working
I created my own MyScrollbarUI class to have a custom scrollbar look in my
I have created a very basic custom layout to set out a menu made
I have created custom menu in my application, i have already set its background,border

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.