Use Customized LinearGradientBrush to paint a Rectangle : Rectangle « Windows Presentation Foundation « VB.Net






Use Customized LinearGradientBrush to paint a Rectangle

Use Customized LinearGradientBrush to paint a Rectangle
       

<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="100" Width="300">
    <Grid>
        <Grid.Resources>
            <LinearGradientBrush x:Key="VisibleSpectrumBrush" StartPoint="0,0" EndPoint="1,0">
                <GradientStop Color="Red" Offset="0.15" />
                <GradientStop Color="Orange" Offset="0.2" />
                <GradientStop Color="Yellow" Offset="0.35" />
            </LinearGradientBrush>
        </Grid.Resources>
        <StackPanel>
            <Rectangle Height="30" Width="280" Fill="{StaticResource VisibleSpectrumBrush}" />
        </StackPanel>
    </Grid>
</Window>

   
    
    
    
    
    
    
  








Related examples in the same category

1.Use Rectangle, TextBlock and Button as the VisualBrushUse Rectangle, TextBlock and Button as the VisualBrush
2.Set Stroke, StrokeThickness for RectangleSet Stroke, StrokeThickness for Rectangle
3.Fill Rectangles with static ImageBrush resourcesFill Rectangles with static ImageBrush resources
4.Fill Rectangle with BisqueFill Rectangle with Bisque
5.Rotating rectanglesRotating rectangles
6.Rounded rectangleRounded rectangle
7.Rectangle with explicit size and positionRectangle with explicit size and position
8.Rectangles with size and position controlled by parentRectangles with size and position controlled by parent
9.Using ImageBrush to fill a RectangleUsing ImageBrush to fill a Rectangle
10.Draws a 100 by 50 rectangle with a solid blue fillDraws a 100 by 50 rectangle with a solid blue fill
11.Draws a 100 by 50 rectangle with a solid blue fill, a black outline, and rounded cornersDraws a 100 by 50 rectangle with a solid blue fill, a black outline, and rounded corners
12.Rectangle StrokeThicknessRectangle StrokeThickness
13.Rectangle.StrokeRectangle.Stroke
14.Set RadiusX and RadiuxY for RectangleSet RadiusX and RadiuxY for Rectangle
15.Fill Rectangle with LinearGradientBrush static resourceFill Rectangle with LinearGradientBrush static resource
16.Using a DrawingBrush resource to draw RectangleUsing a DrawingBrush resource to draw Rectangle
17.A rectangle with a linear fillA rectangle with a linear fill
18.A large rectangle built using an image brushA large rectangle built using an image brush
19.Fill Rectangle with ResourceFill Rectangle with Resource
20.Add Rectangle.Triggers collection into a styleAdd Rectangle.Triggers collection into a style
21.DashArray StrokeDashArray Stroke
22.Dash patternsDash patterns
23.Put Rectangle into TextBlockPut Rectangle into TextBlock
24.Rectangle mouse down eventRectangle mouse down event
25.Rectangle mouse down previewRectangle mouse down preview
26.Change MaxHeightChange MaxHeight