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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:10:49+00:00 2026-06-12T10:10:49+00:00

I just want to create a slider in my C# WPF project and write

  • 0

I just want to create a slider in my C# WPF project and write the value of the slider into a label. I know this is probably really easy to do but I can’t manage to get it working. So here is my slider in my XAML code:

<Slider Height="21" Minimum="-255" Maximum="255" x:Name="sld_brightness" />
<Label x:Name="lb_brightness_nb" />

Now, I try to change the value of the label according to the slider value in my C# code:

public void sld_brightness_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
    lb_brightness_nb.Content = (int)sld_brightness.Value;
}

This code does compile but doesn’t do anything. It is not working. What’s wrong?

  • 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-12T10:10:50+00:00Added an answer on June 12, 2026 at 10:10 am

    You could bind it directly; there’s no need to create an event handler for this.

    <Slider Height="21" Minimum="-255" Maximum="255" x:Name="sld_brightness" />
    <Label x:Name="lb_brightness_nb"
        Content="{Binding ElementName=sld_brightness,Path=Value,Converter={StaticResource DoubleToStringConverter}}" />
    

    If you want to use the event handler, then it looks like you’re missing the wireup:

    <Slider Height="21" Minimum="-255" Maximum="255" x:Name="sld_brightness"
        ValueChanged="sld_brightness_ValueChanged" />
    

    Edit

    To show only the integer, use an IValueConverter. Add it to the resources section using <local:DoubleToStringConverter x:Key="DoubleToStringConverter" />.

    public class DoubleToStringConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return Math.Round((double)value);
        }
    
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just want to understand why I cannot create a protected enum on C#?
How can I create my own login form on frontend? I don’t just want
For our deployments, I just want to drop the existing stored proc, then re-create
Originally, I just want to verify that session_start locks on session. So, I create
I'm looking for as simple way to create an identity set. I just want
I want to create a button in c# with no content but just a
I've just got my Flash Builder 4 and now I want to create a
I've just created anew schema & want to create a new table. When ever
I'm just getting the basics down for objective c. I want to create a
I just want to know if the cookies are created while I try to

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.