From predefined color name in the Colors class : Color « Windows Presentation Foundation « VB.Net






From predefined color name in the Colors class

From predefined color name in the Colors class
    
<Window x:Class="WpfApplication1.SolidColorBrushExample"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Title="SolidColorBrush Example" Height="415" Width="270">
  <Canvas Margin="5">
    <StackPanel>
      <TextBlock Margin="0,10,0,5">
        From predefined color name in the Colors class:
      </TextBlock>
      <Rectangle x:Name="rect2" Width="100" Height="30"
        Stroke="Blue" />


    </StackPanel>
  </Canvas>
</Window>

//File:Window.xaml.vb
Imports System
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Shapes


Namespace WpfApplication1
  Public Partial Class SolidColorBrushExample
    Inherits Window
    Public Sub New()
      InitializeComponent()
      Dim brush As New SolidColorBrush()

      ' From predefined color name in the Colors class: 
      brush = New SolidColorBrush(Colors.Green)

      rect2.Fill = brush
    End Sub

  End Class
End Namespace

   
    
    
    
  








Related examples in the same category

1.A Semi-Transparent ButtonA Semi-Transparent Button
2.Use RGB valued semi-transparent color to paint EllipseUse RGB valued semi-transparent color to paint Ellipse
3.Use RGB solid color to paint EllipseUse RGB solid color to paint Ellipse
4.Rainbow color Animation by GradientStops[index].offsetRainbow color Animation by GradientStops[index].offset
5.RadialGradient StarRadialGradient Star
6.ColorConverter and SolidColorBrushColorConverter and SolidColorBrush
7.Ellipse with explicit SolidColorBrushEllipse with explicit SolidColorBrush
8.Use System Colors in Your GraphicsUse System Colors in Your Graphics
9.Use RGB color to fill RectangleUse RGB color to fill Rectangle
10.Use Named color to paint RectangleUse Named color to paint Rectangle
11.Create semi-transparent colorCreate semi-transparent color
12.Three stops LinearGradientBrushThree stops LinearGradientBrush
13.Animating Color with ColorAnimationAnimating Color with ColorAnimation
14.From a Hex string using ColorConverterFrom a Hex string using ColorConverter
15.From ScRGB values in the Color structureFrom ScRGB values in the Color structure
16.From sRGB values in the Color strutcureFrom sRGB values in the Color strutcure
17.Using a LinearGradientBrushUsing a LinearGradientBrush
18.Multiple gradient stopsMultiple gradient stops
19.Numeric color valuesNumeric color values
20.Using SystemColors in CodeUsing SystemColors in Code
21.using system colors to create gradientsusing system colors to create gradients