Basic DialogBox

image_pdfimage_print


   
      

<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

image_pdfimage_print


   
      

<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

image_pdfimage_print


   
      

<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

image_pdfimage_print


   
      



<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

image_pdfimage_print


   
     

<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>

   
    
    
    
    
     


Multicolored Gradient

image_pdfimage_print


   
     

<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="4" Margin="5">
      <Rectangle.Fill>
        <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
          <GradientStop Color="Yellow" Offset="0.0" />
          <GradientStop Color="Red" Offset="0.25" />
          <GradientStop Color="Blue" Offset="0.75" />
          <GradientStop Color="LimeGreen" Offset="1.0" />
        </LinearGradientBrush>
      </Rectangle.Fill>
    </Rectangle>
    <TextBlock Grid.Row="4" Grid.Column="1" VerticalAlignment="Center" Margin="5">Multicolored Gradient</TextBlock>


  </Canvas>
</Page>

   
    
    
    
    
     


Shape Union

image_pdfimage_print


   
     
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="Microsoft.Samples.Graphics.RectangleExample"
    Title="Example">
    <Window.Resources>
        <RectangleGeometry x:Key="rect" Rect="0 0 100 100"></RectangleGeometry>
        <EllipseGeometry x:Key="ellipse" Center="85 50" RadiusX="65" RadiusY="35"></EllipseGeometry>
    </Window.Resources>
    <Canvas>
        <Path Fill="Yellow" Stroke="Blue" Margin="5">
            <Path.Data>
                <CombinedGeometry GeometryCombineMode="Union"
            CombinedGeometry.Geometry1="{StaticResource rect}"
            CombinedGeometry.Geometry2="{StaticResource ellipse}">
                </CombinedGeometry>
            </Path.Data>
        </Path>
        <TextBlock Margin="10" VerticalAlignment="Center">Union</TextBlock>

    </Canvas>
</Window>