Using SystemColors in Code : Color « Windows Presentation Foundation « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Date Time
8.Design Patterns
9.Development Class
10.Event
11.File Stream
12.Generics
13.GUI Windows Form
14.Internationalization I18N
15.Language Basics
16.LINQ
17.Network
18.Office
19.Reflection
20.Regular Expressions
21.Security
22.Services Event
23.Thread
24.Web Services
25.Windows
26.Windows Presentation Foundation
27.XML
28.XML LINQ
C# / C Sharp » 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.cs

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Data;

namespace SystemColorsAndBrushes_csharp
{
    public partial class Window1 : Window
    {
        public Window1() {
            InitializeComponent();
            System.Windows.Controls.TextBlock t = new System.Windows.Controls.TextBlock();
            t.Text = "ActiveBorder";
            System.Windows.Shapes.Rectangle r = 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";
            System.Windows.Controls.Button b = 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);
        }

    }
}

   
    
  
Related examples in the same category
1.Color AnimationColor Animation
2.Highlights the gradient origin and the gradient circle
3.using Color structuresusing Color structures
4.Use System Color to draw LineUse System Color to draw Line
5.This text uses a gradientThis text uses a gradient
6.Diagonal Linear GradientDiagonal Linear Gradient
7.A Partially Transparent ButtonA Partially Transparent Button
8.A Radial GradientA Radial Gradient
9.A Radial Gradient with an Offset CenterA Radial Gradient with an Offset Center
10.GradientStop with Transparent colorGradientStop with Transparent color
11.Simulating lighting effects with linear fillsSimulating lighting effects with linear fills
12.Color Converter With String FormatColor Converter With String Format
13.Colors and BrushesColors and Brushes
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.From predefined color name in the Colors classFrom predefined color name in the Colors class
18.Fills the polylines with a light gray colorFills the polylines with a light gray color
19.using system colors to create gradientsusing system colors to create gradients
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.