2

I want to change the thickness of ticks and the shape of a tick (arrow shaped etc...) beneath a slider in WPF. I have looked everywhere. What i found was only how to change the height and the color of ticks.

Jolta
  • 2,620
  • 1
  • 29
  • 42

1 Answers1

1

Not a great solution but you can make a custom template and then add a UniformGrid with the desired items.

To add a custom template, add a slider to your xaml. Assuming you are using visual studio, you can go to the Properties Window and under the Miscellaneous section you can go to Templates -> Convert to New Resource.

From here you will be able to make changes to the default template.

Just under the TickBars, I added a UniformGrid. You can remove the TickBars but I left them to show as a comparison in the picture below.

<UniformGrid Columns="11">
    <TextBlock Text="&#x25BC;" TextAlignment="Left"/>
    <TextBlock Text="&#x25BC;" TextAlignment="Left" Margin="7,0,0,0"/>
    <TextBlock Text="&#x25BC;" TextAlignment="Left" Margin="13,0,0,0"/>
    <TextBlock Text="&#x25BC;" TextAlignment="Left" Margin="20,0,0,0"/>
    <TextBlock Text="&#x25BC;" TextAlignment="Left" Margin="24,0,0,0"/>
    <TextBlock Text="&#x25BC;" TextAlignment="Center"/>
    <TextBlock Text="&#x25BC;" TextAlignment="Right" Margin="0,0,24,0"/>
    <TextBlock Text="&#x25BC;" TextAlignment="Right" Margin="0,0,20,0"/>
    <TextBlock Text="&#x25BC;" TextAlignment="Right" Margin="0,0,13,0"/>
    <TextBlock Text="&#x25BC;" TextAlignment="Right" Margin="0,0,7,0"/>
    <TextBlock Text="&#x25BC;" TextAlignment="Right"/>
</UniformGrid>

The text is for a down arrow. You can find other arrows here.

The first, middle, and last textblock will align with where the ticks would normally be. The rest will need offsets, which is what the margins are for. They will be equal on each side, but note that this isn't very reasonable to hard code these unless you know the control will not change size. If the control changes size, you will have to do some math to generate both the font and the margins dynamically.

I changed my foreground and background colors for better visibility but you should end up with something like this.

enter image description here

Sudsy1002
  • 588
  • 6
  • 21