<CustomClass1 Property1="{Binding Source={x:Static DateTime.Now}, Path=Day}"/>
Binding my_binding = new Binding();my_binding.Source = my_data_object;
<TextBlock Width="{Binding RelativeSource={RelativeSource Self}, Path=Parent.ActualWidth}"/>
binding my_binding = new Binding();my_binding.RelativeSource = RelativeSource.Self;
<StackPanel Background="Blue"><TextBlock Background="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type StackPanel}, AncestorLevel=1},Path=Background}" /></StackPanel>
Binding new_binding = new Binding();new_binding.RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(StackPanel), 1);
<Window><Window.Resources><ControlTemplate x:Key="myButtonTemplate" TargetType="{x:Type Button}"><StackPanel Background="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Background}"/></ControlTemplate></Window.Resources><Button Template="{StaticResource myButtonTemplate}" Background="Blue"/></Window>
Binding new_binding = new Binding();new_binding.RelativeSource = RelativeSource.TemplatedParent;
<StackPanel Background="Blue"><Button x:Name="refButton" Background="Orange"/><Button Background="{Binding ElementName=refButton, Path=Background}"/></StackPanel>
Binding new_binding = new Binding();new_binding.ElementName = "refButton";