First, you need to specify ScaleTransformand Slidername in XAML
In this case, the button
<Button.RenderTransform>
<ScaleTransform x:Name="btnScaleTransform" />
</Button.RenderTransform>
Then you create Bindingand use BindingOperations.SetBindingtoegether to connect to things.
var aBinding = new Binding();
aBinding.ElementName = "slider1";
aBinding.Path = new PropertyPath("Value");
BindingOperations.SetBinding(
btnScaleTransform,
ScaleTransform.ScaleXProperty,
aBinding);
Edit:
If you want to declare a slider in the code, you use .Sourceinstead.ElementName
var slider1 = new Slider();
grid1.Children.Add(slider1);
var aBinding = new Binding();
aBinding.Source = slider1;
aBinding.Path = new PropertyPath("Value");
source
share