Tile VisualBrush


   
     
<Page  
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
  x:Class="Microsoft.Samples.Graphics.UsingVisualBrush.PaintingWithVisuals">
    <StackPanel>
        <Rectangle Width="150" Height="150" Stroke="Black" Margin="0,0,5,0">
            <Rectangle.Fill>
                <VisualBrush Viewport="0,0,95,35" ViewportUnits="Absolute" TileMode="Tile">
                    <VisualBrush.Visual>
                        <StackPanel Background="Transparent">
                            <TextBlock FontSize="10pt" Margin="10">Hello, World!</TextBlock>
                        </StackPanel>
                    </VisualBrush.Visual>
                </VisualBrush>
            </Rectangle.Fill>
        </Rectangle>
    </StackPanel>
</Page>

   
    
    
    
    
     


VisualBrush Binding to a Button


   
     
<Window x:Class="Drawing.VisualBrush"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="VisualBrush" Height="300" Width="300"
    >
  <StackPanel Margin="3">
    <Button Name="cmd" Margin="3" Padding="5">Is this a real button?</Button>
    <Rectangle Margin="3" Height="{Binding ElementName=cmd,Path=ActualHeight}">
      <Rectangle.Fill>
        <VisualBrush Visual="{Binding ElementName=cmd}"></VisualBrush>
      </Rectangle.Fill>
    </Rectangle>
    <Rectangle Margin="3" Height="50">
      <Rectangle.Fill>
        <VisualBrush Visual="{Binding ElementName=cmd}"></VisualBrush>
      </Rectangle.Fill>
    </Rectangle>
    <Rectangle Margin="3" Height="150">
      <Rectangle.Fill>
        <VisualBrush Visual="{Binding ElementName=cmd}"></VisualBrush>
      </Rectangle.Fill>
    </Rectangle>
  </StackPanel>
</Window>

   
    
    
    
    
     


Basic DialogBox


   
      

<Window x:Class="Styles.BasicDialogBox"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="BasicDialogBox" Height="300" Width="300" MinHeight="150" MinWidth="200">
  <Window.Resources>
    <Thickness x:Key="BasicMargin" Bottom="5" Top="5" Left="5" Right="5"></Thickness>
  </Window.Resources>
  <DockPanel LastChildFill="True">
    <StackPanel DockPanel.Dock="Bottom" HorizontalAlignment="Right" Orientation="Horizontal">
      <Button Margin="{StaticResource BasicMargin}" Padding="3,3,3,3">OK</Button>
      <Button Margin="{StaticResource BasicMargin}" Padding="3,3,3,3">Cancel</Button>
      
    </StackPanel>
    <TextBox DockPanel.Dock="Top" Margin="10">This is a test.</TextBox>
  </DockPanel>
</Window>

   
    
    
    
    
    
     


Window ResizeMode=CanMinimize


   
      

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        Title="Compile XAML Only"
        SizeToContent="WidthAndHeight"
        ResizeMode="CanMinimize">
    <StackPanel>

        <Button HorizontalAlignment="Center"
                Margin="24">
            Just a Button
        </Button>

        <Ellipse Width="200"
                 Height="100"
                 Margin="24" 
                 Stroke="Red"
                 StrokeThickness="10" />

        <ListBox Width="100"
                 Height="100"
                 Margin="24">
            <ListBoxItem>Sunday</ListBoxItem>
            <ListBoxItem>Monday</ListBoxItem>
            <ListBoxItem>Tuesday</ListBoxItem>
            <ListBoxItem>Wednesday</ListBoxItem>
            <ListBoxItem>Thursday</ListBoxItem>
            <ListBoxItem>Friday</ListBoxItem>
            <ListBoxItem>Saturday</ListBoxItem>
        </ListBox>

    </StackPanel>
</Window>

   
    
    
    
    
    
     


Window Background


   
      

<Window x:Class="Drawing.OpacityMask"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="OpacityMask" Height="313.6" Width="317.6"
    >
  <Window.Background>
    <ImageBrush ImageSource="c:image.jpg"></ImageBrush>
  </Window.Background>
    <Grid Margin="10,50">

    </Grid>
</Window>

   
    
    
    
    
    
     


Set Window Height and Width


   
      



<Window x:Class="WpfApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="WrapPanelWindow" Height="300" Width="300">
    <WrapPanel>
        <Button Width="30">A</Button>
        <Button Width="30">B</Button>
        <Button Width="30">C</Button>
        <Button Width="30">D</Button>
        <Button Width="30">E</Button>
        <Button Width="30">F</Button>
        <Button Width="30">G</Button>
        <Button Width="30">H</Button>
        <Button Width="30">I</Button>
        <Button Width="30">J</Button>
        <Button Width="30">K</Button>
        <Button Width="30">L</Button>
        <Button Width="30">M</Button>
        <Button Width="30">N</Button>
        <Button Width="30">O</Button>
        <Button Width="30">P</Button>
    </WrapPanel>
</Window>

   
    
    
    
    
    
     


Reflected Gradient


   
     

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="Microsoft.Samples.Graphics.RectangleExample"
    WindowTitle="Example">
  <Canvas>

    <Rectangle Width="150" Height="100" Grid.Row="3" Margin="5">
      <Rectangle.Fill>
        <LinearGradientBrush StartPoint="0,0" EndPoint="0,0.5" SpreadMethod="Reflect">
          <GradientStop Color="Blue" Offset="0"/>
          <GradientStop Color="White" Offset="1" />
        </LinearGradientBrush>
      </Rectangle.Fill>
    </Rectangle>
    <TextBlock Grid.Row="3" Grid.Column="1" VerticalAlignment="Center" Margin="5">Reflected Gradient</TextBlock>
    
  </Canvas>
</Page>