I have an instance of a user control in my project that contains a slider. I would like to bind the ScaleTransform of a RichTextBox control to the value of the slider but I do not know how to properly reference it. The user control is called toolbar and the slider inside it is called Scale this is what I have tried so far:
<RichTextBox x:Name="body"
SelectionChanged="body_SelectionChanged"
SpellCheck.IsEnabled="True"
AcceptsReturn="True" AcceptsTab="True"
BorderThickness="0 2 0 0">
<RichTextBox.LayoutTransform>
<ScaleTransform ScaleX="{Binding ElementName=toolbar.Scale, Path=Value}" ScaleY="{Binding ElementName=toolbar.Scale, Path=Value}"/>
</RichTextBox.LayoutTransform>
</RichTextBox>
I have also tried doing it in the .cs file since I’m having trouble with the binding but haven’t had any luck figuring out how to actually set the transform values once my slider event has been fired.
You cannot reference names inside other controls, they are in another name-scope. If you need the slider value bind it to a property of the
UserControl.UserControlcode (whatever that class may be called in your case):New binding code: