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

  • Home
  • SEARCH
  • 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 4009522
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:53:18+00:00 2026-05-20T08:53:18+00:00

I am trying to databind some graphics to a slider to adjust the graphic

  • 0

I am trying to databind some graphics to a slider to adjust the graphic size in code-behind.
I tried various ways but I can’t find a way to bind the the ScaleTransform’s ScaleX property in C# code. (I’m generating this in run-time code, so no XAML)

Here is my sample code, which doesn’t work

Line lR = new Line();
lR.X1 = 0;
lR.Y1 = 0;
lR.X2 = 150;
lR.Y2 = 150;
lR.Stroke = new SolidColorBrush(Colors.Blue);
lR.StrokeThickness = 2;

ScaleTransform lRSt = new ScaleTransform();
lR.RenderTransform = lRSt;

Slider sliderR = new Slider();
sliderR.Minimum = 1;
sliderR.Maximum = 3;
sliderR.Value = 1;
sliderR.TickPlacement = TickPlacement.BottomRight;
sliderR.TickFrequency = 0.2;
sliderR.IsSnapToTickEnabled = true;

/* Set Binding between Slider and Canvas Children */
Binding sliderRBind1 = new Binding();
sliderRBind1.Source = sliderRBind1;
sliderRBind1.Path = new PropertyPath("Value");
BindingOperations.SetBinding(lRSt, ScaleTransform.ScaleXProperty, sliderRBind1);
  • 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-05-20T08:53:19+00:00Added an answer on May 20, 2026 at 8:53 am

    First you need to give the ScaleTransform and the Slider a name in the XAML

    In this case a Button

    <Button.RenderTransform>
        <ScaleTransform x:Name="btnScaleTransform" />
    </Button.RenderTransform>
    

    Then you create a Binding and use BindingOperations.SetBinding to wire things toegether.

    var aBinding = new Binding();
    aBinding.ElementName = "slider1"; // name of the slider
    aBinding.Path = new PropertyPath("Value");
    
    BindingOperations.SetBinding(
        btnScaleTransform, // the ScaleTransform to bind to
        ScaleTransform.ScaleXProperty,
        aBinding);            
    

    Edit:
    If you want to declare the slider in code too you use .Source instead of .ElementName

    var slider1 = new Slider();
    grid1.Children.Add(slider1);
    
    var aBinding = new Binding();
    aBinding.Source = slider1;
    aBinding.Path = new PropertyPath("Value");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to databind some information to a repeater but it seems to be
I am trying to debug some code in my code behind files for as
For some time now I am trying to figure out how I can refactor
I am trying to add a new row into a gridview but for some
I'm trying to databind my repeater but so far not having any luck. Anyone
I am trying to read through the dataBind documentation, but it's not all that
I was trying to figure this out for quite some time.I want a Databind
I'm trying to use lambdas in some VB.Net code, essentially I'm trying to set
I'm trying to change over some ASP.NET code to use the strongly-typed translations we're
I'm trying to Databind to my custom dictionary class. In formLoad, I can bind

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.