About Dialog


   
      


<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  Title="About WPF" SizeToContent="WidthAndHeight"
  Background="OrangeRed">
  <StackPanel>
  <Label FontWeight="Bold" FontSize="20" Foreground="White">
    WPF Version 
  </Label>
  <Label>2006</Label>
  <Label>Installed DLL:</Label>
  <ListBox>
    <ListBoxItem>1</ListBoxItem>
    <ListBoxItem>2</ListBoxItem>
  </ListBox>
  <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
    <Button MinWidth="75" Margin="10">Help</Button>
    <Button MinWidth="75" Margin="10">OK</Button>
  </StackPanel>
  <StatusBar>You have successfully registered this product.</StatusBar>
  </StackPanel>
</Window>

   
    
    
    
    
    
     


Define the Tab Order of UI Elements in a Form


   
      

<Window x:Class="WpfApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="WPF" Height="200" Width="300">
    <StackPanel>
        <Button Content="Button _A (1st tab)" TabIndex="0" Margin="2" />
        <Button Content="Button _B (4th tab)" TabIndex="3" Margin="2" />
        <Button Content="Button _C (2nd tab)" TabIndex="1" Margin="2" />
        <Button Content="Button _D (5th tab)" TabIndex="4" Margin="2" />
        <Button Content="Button _E (3rd tab)" TabIndex="2" Margin="2" />
        <Button Content="Button _F (6th tab)" TabIndex="5" Margin="2" />
    </StackPanel>
</Window>

   
    
    
    
    
    
     


Control the Size of UI Elements in a Form


   
      

<Window x:Class="WpfApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="WPF" Height="300" Width="400">
    <StackPanel Margin="5" Orientation="Vertical">
        <Button Content="Button _A" Margin="2" />
        <Button Content="Button _B" HorizontalAlignment="Left" />
        <Button Content="Button _C" HorizontalAlignment="Center" />
        <Button Content="Button _D" HorizontalAlignment="Right" />
        <Button Content="Button _E" Height="40" Margin="2" />
        <Button Content="Button _F" Width="80" Margin="2" />
        <Button Content="Button _G" MinHeight="30" Margin="2" />
        <Button Content="Button _H" MinWidth="120" Margin="10,5,5,10" />
        <Button Content="Button _I" MaxWidth="200" Margin="2" />
    </StackPanel>
</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>

   
    
    
    
    
    
     


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>

   
    
    
    
    
    
     


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>

   
    
    
    
    
    
     


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>