Bind RelativeSource's AncestorType

image_pdfimage_print


   
   
<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            TextBlock.FontSize="12" >
    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
        <TextBlock Text="This TextBlock is inside a StackPanel with " />
        <TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType={x:Type StackPanel}}, Path=Orientation}" />
        <TextBlock Text=" orientation" />
    </StackPanel>


</StackPanel>