Mega Code Archive

 
Categories / VB.Net Tutorial / WPF
 

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