<Window x:Class="WPFBrushes.SolidColorBrushInCode"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WPFBrushes" Height="300" Width="300"
>
<Grid>
</Grid>
</Window>
//File:Window.xaml.vb
Imports System.Windows
Imports System.Windows.Documents
Imports System.Windows.Controls
Imports System.Windows.Media
Imports System.Windows.Shapes
Namespace WPFBrushes
Public Partial Class SolidColorBrushInCode
Inherits System.Windows.Window
Public Sub New()
InitializeComponent()
Me.Width = 600
Dim sp As New StackPanel()
sp.Margin = New Thickness(4.0)
sp.HorizontalAlignment = HorizontalAlignment.Left
sp.Orientation = Orientation.Vertical
Dim tb1 As New TextBlock(New Run("Brush from Predefined Color [ .Fill = new SolidColorBrush(Colors.Green); ]"))
Dim rect1 As New Rectangle()
rect1.HorizontalAlignment = HorizontalAlignment.Left
rect1.Width = 60
rect1.Height = 20
rect1.Fill = New SolidColorBrush(Colors.Green)
sp.Children.Add(tb1)
sp.Children.Add(rect1)
Me.Content = sp
End Sub
End Class
End Namespace