Binding modes
TwoWay source <-> target
OneTime source -> target only once
OneWayToSource source <- target
Default is OneWay (except for textboxes(it is Twoway for textbox)
Simple element binding
<Slider Name="mySlider"
Margin="3"
Minimum="1"
Maximum="40"
Value="10"
TickFrequency="1"
TickPlacement="TopLeft">
</Slider>
<TextBlock Margin="81,126,185,125"
Text="Simple Text"
Name="myTextBox"
FontSize="{Binding ElementName=mySlider, Path=Value, Mode=TwoWay}">
</TextBlock>
To do samething programmatically
Binding b = new Binding();
b.Source = mySlider;
b.Path = new PropertyPath("Value");
b.Mode = BindingMode.TwoWay;
//BindingOperations.ClearAllBindings(myTextBox); // a way to reset
myTextBox.SetBinding(TextBlock.FontSizeProperty, b);
If you are not binding to an element, you are binding to one of the following
(instead of ElementName=)
Source. object that's supplying .
RelativeSource. path or pointer to source object.
DataContext. finding by nearest parents datacontext object
Calling system resource/ window resource
<Window.Resources>
<FontFamily x:Key="windowResource">sometext</FontFamily>
</Window.Resources>
<TextBlock Text="{Binding Source={x:Static SystemFonts.IconFontFamily}, Path=Source}"></TextBlock>
<TextBlock Text="{Binding Source={StaticResource windowResource},Path=Source}"></TextBlock>