Using SystemColors in Code : Color « Windows Presentation Foundation « VB.Net

Home
VB.Net
1.2D
2.Application
3.Class
4.Data Structure
5.Data Types
6.Database ADO.net
7.Development
8.Event
9.File Directory
10.Generics
11.GUI
12.Language Basics
13.LINQ
14.Network Remote
15.Security
16.Thread
17.Windows Presentation Foundation
18.Windows System
19.XML
20.XML LINQ
VB.Net Tutorial
VB.Net by API
VB.Net » Windows Presentation Foundation » ColorScreenshots 
Using SystemColors in Code
Using SystemColors in Code
     
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="SystemColorsAndBrushes_csharp.Window1"
    Title="System Colors" >
   <Window.Resources>
    <Style TargetType="{x:Type Rectangle}">
      <Setter Property="Margin" Value="10,0,10,0"/>
      <Setter Property="HorizontalAlignment" Value="Left"/>
      <Setter Property="Height" Value="20"/>
      <Setter Property="Width" Value="120"/>
      <Setter Property="Stroke" Value="Black"/>
      <Setter Property="StrokeThickness" Value="1"/>
    </Style>
    <Style TargetType="{x:Type TextBlock}">
      <Setter Property="Margin" Value="10,20,10,0"/>
    </Style>
    <Style TargetType="{x:Type Button}">
      <Setter Property="Margin" Value="10,0,10,0"/>
      <Setter Property="HorizontalAlignment" Value="Left"/>
    </Style>
    </Window.Resources>
    <ScrollViewer>

    <Grid>
      <Grid.ColumnDefinitions>
        <ColumnDefinition />
        <ColumnDefinition Width="5" />
        <ColumnDefinition />
      </Grid.ColumnDefinitions>
      <Grid.RowDefinitions>
        <RowDefinition />
      </Grid.RowDefinitions>
      <Rectangle Grid.Column="1" Grid.Row="0" 
        HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Fill="Black"
        RadiusX="10" RadiusY="10" />
    
      <StackPanel Name="systemBrushesPanel" Background="White" Grid.Row="0" Grid.Column="0"/> 
      <StackPanel Name="gradientExamplePanel" Background="White" Grid.Row="0" Grid.Column="2"/>

  </Grid>
  
  </ScrollViewer>
</Window>

//File:Window.xaml.vb

Imports System
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Documents
Imports System.Windows.Navigation
Imports System.Windows.Shapes
Imports System.Windows.Data

Namespace SystemColorsAndBrushes_csharp
  Public Partial Class Window1
    Inherits Window
    Public Sub New()
      InitializeComponent()
      Dim As New System.Windows.Controls.TextBlock()
      t.Text = "ActiveBorder"
      Dim As New System.Windows.Shapes.Rectangle()
      r.Fill = SystemColors.ActiveBorderBrush
      systemBrushesPanel.Children.Add(t)
      systemBrushesPanel.Children.Add(r)

      t = New System.Windows.Controls.TextBlock()
      t.Text = "ActiveCaption"
      r = New System.Windows.Shapes.Rectangle()
      r.Fill = SystemColors.ActiveCaptionBrush
      systemBrushesPanel.Children.Add(t)
      systemBrushesPanel.Children.Add(r)

      t = New System.Windows.Controls.TextBlock()
      t.Text = "ActiveCaptionText"
      r = New System.Windows.Shapes.Rectangle()
      r.Fill = SystemColors.ActiveCaptionTextBrush
      systemBrushesPanel.Children.Add(t)
      systemBrushesPanel.Children.Add(r)

      t = New System.Windows.Controls.TextBlock()
      t.Text = "AppWorkspace"
      r = New System.Windows.Shapes.Rectangle()
      r.Fill = SystemColors.AppWorkspaceBrush
      systemBrushesPanel.Children.Add(t)
      systemBrushesPanel.Children.Add(r)

      t = New System.Windows.Controls.TextBlock()
      t.Text = "Control"
      r = New System.Windows.Shapes.Rectangle()
      r.Fill = SystemColors.ControlBrush
      systemBrushesPanel.Children.Add(t)
      systemBrushesPanel.Children.Add(r)

      t = New System.Windows.Controls.TextBlock()
      t.Text = "ControlDark"
      r = New System.Windows.Shapes.Rectangle()
      r.Fill = SystemColors.ControlDarkBrush
      systemBrushesPanel.Children.Add(t)
      systemBrushesPanel.Children.Add(r)

      t = New System.Windows.Controls.TextBlock()
      t.Text = "ControlDarkDark"
      r = New System.Windows.Shapes.Rectangle()
      r.Fill = SystemColors.ControlDarkDarkBrush
      systemBrushesPanel.Children.Add(t)
      systemBrushesPanel.Children.Add(r)

      t = New System.Windows.Controls.TextBlock()
      t.Text = "ControlLight"
      r = New System.Windows.Shapes.Rectangle()
      r.Fill = SystemColors.ControlLightBrush
      systemBrushesPanel.Children.Add(t)
      systemBrushesPanel.Children.Add(r)

      t = New System.Windows.Controls.TextBlock()
      t.Text = "ControlLightLight"
      r = New System.Windows.Shapes.Rectangle()
      r.Fill = SystemColors.ControlLightLightBrush
      systemBrushesPanel.Children.Add(t)
      systemBrushesPanel.Children.Add(r)

      t = New System.Windows.Controls.TextBlock()
      t.Text = "ControlText"
      r = New System.Windows.Shapes.Rectangle()
      r.Fill = SystemColors.ControlTextBrush
      systemBrushesPanel.Children.Add(t)
      systemBrushesPanel.Children.Add(r)

      t = New System.Windows.Controls.TextBlock()
      t.Text = "Desktop"
      r = New System.Windows.Shapes.Rectangle()

      r.SetResourceReference(System.Windows.Shapes.Shape.FillProperty, System.Windows.SystemColors.DesktopBrushKey)

      systemBrushesPanel.Children.Add(t)
      systemBrushesPanel.Children.Add(r)

      t = New System.Windows.Controls.TextBlock()
      t.Text = "GradientActiveCaption"
      r = New System.Windows.Shapes.Rectangle()
      r.Fill = SystemColors.GradientActiveCaptionBrush
      systemBrushesPanel.Children.Add(t)
      systemBrushesPanel.Children.Add(r)

      t = New System.Windows.Controls.TextBlock()
      t.Text = "GradientInactiveCaption"
      r = New System.Windows.Shapes.Rectangle()
      r.Fill = SystemColors.GradientInactiveCaptionBrush
      systemBrushesPanel.Children.Add(t)
      systemBrushesPanel.Children.Add(r)

      t = New System.Windows.Controls.TextBlock()
      t.Text = "GrayText"
      r = New System.Windows.Shapes.Rectangle()
      r.Fill = SystemColors.GrayTextBrush
      systemBrushesPanel.Children.Add(t)
      systemBrushesPanel.Children.Add(r)

      t = New System.Windows.Controls.TextBlock()
      t.Text = "Highlight"
      r = New System.Windows.Shapes.Rectangle()
      r.Fill = SystemColors.HighlightBrush
      systemBrushesPanel.Children.Add(t)
      systemBrushesPanel.Children.Add(r)

      t = New System.Windows.Controls.TextBlock()
      t.Text = "HighlightText"
      r = New System.Windows.Shapes.Rectangle()
      r.Fill = SystemColors.HighlightTextBrush
      systemBrushesPanel.Children.Add(t)
      systemBrushesPanel.Children.Add(r)

      t = New System.Windows.Controls.TextBlock()
      t.Text = "HotTrack"
      r = New System.Windows.Shapes.Rectangle()
      r.Fill = SystemColors.HotTrackBrush
      systemBrushesPanel.Children.Add(t)
      systemBrushesPanel.Children.Add(r)

      t = New System.Windows.Controls.TextBlock()
      t.Text = "InactiveBorder"
      r = New System.Windows.Shapes.Rectangle()
      r.Fill = SystemColors.InactiveBorderBrush
      systemBrushesPanel.Children.Add(t)
      systemBrushesPanel.Children.Add(r)

      t = New System.Windows.Controls.TextBlock()
      t.Text = "InactiveCaption"
      r = New System.Windows.Shapes.Rectangle()
      r.Fill = SystemColors.InactiveCaptionBrush
      systemBrushesPanel.Children.Add(t)
      systemBrushesPanel.Children.Add(r)

      t = New System.Windows.Controls.TextBlock()
      t.Text = "InactiveCaptionText"
      r = New System.Windows.Shapes.Rectangle()
      r.Fill = SystemColors.InactiveCaptionTextBrush
      systemBrushesPanel.Children.Add(t)
      systemBrushesPanel.Children.Add(r)

      t = New System.Windows.Controls.TextBlock()
      t.Text = "Info"
      r = New System.Windows.Shapes.Rectangle()
      r.Fill = SystemColors.InfoBrush
      systemBrushesPanel.Children.Add(t)
      systemBrushesPanel.Children.Add(r)

      t = New System.Windows.Controls.TextBlock()
      t.Text = "InfoText"
      r = New System.Windows.Shapes.Rectangle()
      r.Fill = SystemColors.InfoTextBrush
      systemBrushesPanel.Children.Add(t)
      systemBrushesPanel.Children.Add(r)

      t = New System.Windows.Controls.TextBlock()
      t.Text = "Menu"
      r = New System.Windows.Shapes.Rectangle()
      r.Fill = SystemColors.MenuBrush
      systemBrushesPanel.Children.Add(t)
      systemBrushesPanel.Children.Add(r)

      t = New System.Windows.Controls.TextBlock()
      t.Text = "MenuBar"
      r = New System.Windows.Shapes.Rectangle()
      r.Fill = SystemColors.MenuBarBrush
      systemBrushesPanel.Children.Add(t)
      systemBrushesPanel.Children.Add(r)

      t = New System.Windows.Controls.TextBlock()
      t.Text = "MenuHighlight"
      r = New System.Windows.Shapes.Rectangle()
      r.Fill = SystemColors.MenuHighlightBrush
      systemBrushesPanel.Children.Add(t)
      systemBrushesPanel.Children.Add(r)

      t = New System.Windows.Controls.TextBlock()
      t.Text = "MenuText"
      r = New System.Windows.Shapes.Rectangle()
      r.Fill = SystemColors.MenuTextBrush
      systemBrushesPanel.Children.Add(t)
      systemBrushesPanel.Children.Add(r)

      t = New System.Windows.Controls.TextBlock()
      t.Text = "ScrollBar"
      r = New System.Windows.Shapes.Rectangle()
      r.Fill = SystemColors.ScrollBarBrush
      systemBrushesPanel.Children.Add(t)
      systemBrushesPanel.Children.Add(r)

      t = New System.Windows.Controls.TextBlock()
      t.Text = "Window"
      r = New System.Windows.Shapes.Rectangle()
      r.Fill = SystemColors.WindowBrush
      systemBrushesPanel.Children.Add(t)
      systemBrushesPanel.Children.Add(r)

      t = New System.Windows.Controls.TextBlock()
      t.Text = "WindowFrame"
      Dim As New System.Windows.Controls.Button()
      b.Width = 120
      b.Height = 20
      b.Background = SystemColors.WindowFrameBrush
      systemBrushesPanel.Children.Add(t)
      systemBrushesPanel.Children.Add(b)

      t = New System.Windows.Controls.TextBlock()
      t.Text = "WindowText"
      b = New System.Windows.Controls.Button()
      b.Width = 120
      b.Height = 20
      b.Background = SystemColors.WindowTextBrush
      systemBrushesPanel.Children.Add(t)
      systemBrushesPanel.Children.Add(b)
    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.From predefined color name in the Colors classFrom predefined color name in the Colors class
21.using system colors to create gradientsusing system colors to create gradients
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.