Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleUse XAML to make a grid with a gradient background in VB 2005 and .NET Framework 3.0
DescriptionThis example shows how to use XAML to make a grid with a gradient background in VB 2005 and .NET Framework 3.0.
KeywordsXAML, VB 2005, Visual Basic 2005, .NET Framework 3.0, gradient, grid
CategoriesVB.NET, WPF
 
Inside the XAML Grid element, place a Grid.Background element. Inside that place a gradient brush element. This example uses a LinearGradientBrush that shades colors from the control's upper left corner (0, 0) to its lower right corner (1, 1). The LinearGradientBrush element contains GradientStop elements that indicate that the color should be red at the start, white halfway through, and blue at the end.
 
<Window x:Class="Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="WindowsApplication1" Height="235" Width="300"
    >
    <Grid >
      <Grid.Background>
        <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
          <GradientStop Color="Red" Offset="0.0" />
          <GradientStop Color="White" Offset="0.5" />
          <GradientStop Color="Blue" Offset="1.0" />
        </LinearGradientBrush>
      </Grid.Background>
    </Grid>
</Window>
 
Note that this example uses the .NET Framework 3.0 and XAML. To use them, you need to install the Windows SDK (currently called the Windows Vista SDK) available for download on Microsoft's Web site.
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated