<Page
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="AutoLayoutContent Example"
    >
  <Page.Resources>
    <Style TargetType="{x:Type Rectangle}">
      <Setter Property="HorizontalAlignment" Value="Left" />
    </Style>
    <Style TargetType="{x:Type Button}">
      <Setter Property="HorizontalAlignment" Value="Left" />
    </Style>   
  </Page.Resources>
  
  <StackPanel Margin="20">

    <TextBlock Margin="0,20,0,0">Displaying a non-parented UIElement</TextBlock>
    
    <!-- <SnippetAutoLayoutContentNonParentedUIElementExample> -->
    <StackPanel  Margin="20,0,0,0">
      <TextBlock Margin="0,10,0,0">AutoLayoutContent: True</TextBlock>
      <Rectangle 
        Width="100" 
        Height="100"
        Stroke="Black"
        StrokeThickness="1">
        <Rectangle.Fill>
          <VisualBrush AutoLayoutContent="True">
            <VisualBrush.Visual>
              <Button Content="Hello, World" />
            </VisualBrush.Visual>
          </VisualBrush>
        </Rectangle.Fill>
      </Rectangle>

      <TextBlock Margin="0,10,0,0">AutoLayoutContent: False</TextBlock>
      <Rectangle 
        Width="100" 
        Height="100"
        Stroke="Black"
        StrokeThickness="1">
        <Rectangle.Fill>
          <VisualBrush AutoLayoutContent="False">
            <VisualBrush.Visual>
              <Button Content="Hello, World" Width="100" Height="100" />
            </VisualBrush.Visual>
          </VisualBrush>
        </Rectangle.Fill>
      </Rectangle>
    </StackPanel>
    <!-- </SnippetAutoLayoutContentNonParentedUIElementExample> -->



    <TextBlock Margin="0,20,0,0">Displaying a parented UIElement</TextBlock>

    <!-- <SnippetAutoLayoutContentParentedUIElementExample> -->   
    <StackPanel Margin="20,0,0,0">

      <TextBlock Margin="0,10,0,0">The UIElement</TextBlock>
      <Button Name="MyButton" Content="Hello, World" />

      <TextBlock Margin="0,10,0,0">AutoLayoutContent: True</TextBlock>
      <Rectangle 
            Width="100" 
            Height="100"
            Stroke="Black"
            StrokeThickness="1">
        <Rectangle.Fill>
          <VisualBrush Visual="{Binding ElementName='MyButton'}" />
        </Rectangle.Fill>
      </Rectangle>

      <TextBlock Margin="0,10,0,0">AutoLayoutContent: False</TextBlock>
      <Rectangle 
        Width="100" 
        Height="100"
        Stroke="Black"
        StrokeThickness="1">
        <Rectangle.Fill>
          <VisualBrush Visual="{Binding ElementName='MyButton'}" 
                       AutoLayoutContent="False"/>
        </Rectangle.Fill>
      </Rectangle>
    </StackPanel>
    <!-- </SnippetAutoLayoutContentParentedUIElementExample> -->

  </StackPanel>
  
  
  
</Page>
