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 9198779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:22:05+00:00 2026-06-17T22:22:05+00:00

I have written a custom style (including template) for the slider control in WPF,

  • 0

I have written a custom style (including template) for the slider control in WPF, which has 2 buttons inside (‘MinusBtn” and “PlusBtn”).

Now, I want to use the same slider custom style for 4 different sliders, and I want the buttons to do the same thing when I press it on everyone of the 4 sliders (“MinusBtn_Clicked” event and “PlusBtn_Clisked” event). But I need to know which slider invoked the event.

Since the buttons configured in the generic style, I cannot know it by their parent.
How can I fix this? Can I add parameters to the delegate of this event?

Here is my custom style:

 <Style x:Key="MyCustomStyleForSlider" TargetType="{x:Type Slider}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Slider}">  
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="10.5"/>
                            <RowDefinition Height="Auto" MinHeight="{TemplateBinding Slider.MinHeight}"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="47*"/>
                            <ColumnDefinition Width="331*"/>
                            <ColumnDefinition Width="47*"/>
                        </Grid.ColumnDefinitions>

                        <TickBar Name="BottomTick" SnapsToDevicePixels="True" Grid.Row="2" Fill="{TemplateBinding Foreground}"
                                Placement="Bottom"
                                Height="4"
                                Visibility="Collapsed" />

                        <Grid x:Name="JustTrack" Height="20" Width="335" Grid.RowSpan="1" Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="1">
                            <Track Grid.Row="1" Name="PART_Track">
                                <Track.DecreaseRepeatButton>
                                    <RepeatButton Style="{StaticResource DecreaseSliderButtonStyle}"  />
                                </Track.DecreaseRepeatButton>
                                <Track.Thumb>
                                    <Thumb Style="{StaticResource SliderThumbStyle}" />
                                </Track.Thumb>
                                <Track.IncreaseRepeatButton>
                                    <RepeatButton Style="{StaticResource SliderButtonStyle}" />
                                </Track.IncreaseRepeatButton>
                            </Track>
                        </Grid>
                    <Grid x:Name="Minus" Grid.Column="0" Grid.RowSpan="3" Width="47" Height="40">
                            <Button x:Name="MinusBtn" Click="MinusBtn_Click" >
                                <Button.Template>
                                    <ControlTemplate>
                                        <Ellipse Height="25" Width="25" Fill="Transparent"></Ellipse>
                                    </ControlTemplate>
                                </Button.Template>
                            </Button>
                        </Grid>
                        <Grid x:Name="Plus" Grid.Column="2" Grid.RowSpan="3" Width="47" Height="40">
                            <Button x:Name="PlusBtn" Click="PlusBtn_Click">
                                <Button.Template>
                                    <ControlTemplate>
                                        <Ellipse Height="25" Width="25" Fill="Transparent"></Ellipse>
                                    </ControlTemplate>
                                </Button.Template>
                            </Button>
                        </Grid>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="TickPlacement" Value="BottomRight">
                            <Setter TargetName="BottomTick" Property="Visibility" Value="Visible"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
  • 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-17T22:22:06+00:00Added an answer on June 17, 2026 at 10:22 pm

    If you want to increase or decrease the value of the slider with the buttons. Use the Command property of the buttons:

    <Grid x:Name="Minus" Grid.Column="0" Grid.RowSpan="3" Width="47" Height="40">
        <Button x:Name="MinusBtn" Command="Slider.DecreaseSmall">
            <Button.Template>
                <ControlTemplate>
                    <Ellipse Height="25" Width="25" Fill="Transparent"></Ellipse>
                </ControlTemplate>
            </Button.Template>
        </Button>
    </Grid>
    <Grid x:Name="Plus" Grid.Column="2" Grid.RowSpan="3" Width="47" Height="40">
        <Button x:Name="PlusBtn" Command="Slider.IncreaseSmall">
            <Button.Template>
                <ControlTemplate>
                    <Ellipse Height="25" Width="25" Fill="Transparent"></Ellipse>
                </ControlTemplate>
            </Button.Template>
        </Button>
    </Grid>
    

    Or if you really want the slider in your event handler, you can do:

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        FrameworkElement frameworkElement = (FrameworkElement)sender;
        Slider slider = (Slider)frameworkElement.TemplatedParent;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a custom server control which (pseudo-code) looks like public class MyCustomCtrl
I have written a custom template tag which returns a number of users in
I have a custom built application framework written in PHP which I have been
Assume i have a custom Windows application written in C#. This application has only
I have a custom control in WPF. In this I have a DependencyProperty of
I have written a custom Silverlight control based on Control. I have two DependencyProperties
I have written a custom control that renders some graphics. The graphics itself is
I have written a custom UIGestureRecognizer which handles rotations with one finger. It is
I have written a custom REST compensation framework in spring which records a REST
I have written a Custom Delegating Handler which add custom headers to the response

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.