xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="SystemColorsAndBrushes_csharp.Window1"
Title="System Colors" >
HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Fill="Black"
RadiusX="10" RadiusY="10" />
//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 = "System Color Gradient Examples";
t.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
t.FontWeight = System.Windows.FontWeights.Bold;
gradientExamplePanel.Children.Add(t);
t = new System.Windows.Controls.TextBlock();
t.Text = "ControlDark to ControlLight";
System.Windows.Shapes.Rectangle r = new System.Windows.Shapes.Rectangle();
r.Fill = new System.Windows.Media.RadialGradientBrush(
System.Windows.SystemColors.ControlDarkColor, System.Windows.SystemColors.ControlLightColor);
gradientExamplePanel.Children.Add(t);
gradientExamplePanel.Children.Add(r);
t = new System.Windows.Controls.TextBlock();
t.Text = "ControlDarkDark to ControlLightLight";
r = new System.Windows.Shapes.Rectangle();
r.Fill = new System.Windows.Media.LinearGradientBrush(System.Windows.SystemColors.ControlDarkDarkColor, System.Windows.SystemColors.ControlLightLightColor, 45);
gradientExamplePanel.Children.Add(t);
gradientExamplePanel.Children.Add(r);
// Try it out on a button.
t = new System.Windows.Controls.TextBlock();
t.Text = "Desktop to AppWorkspace";
System.Windows.Controls.Button b = new System.Windows.Controls.Button();
b.Width = 120;
b.Height = 20;
b.Background = new System.Windows.Media.RadialGradientBrush(System.Windows.SystemColors.DesktopColor, System.Windows.SystemColors.AppWorkspaceColor);
gradientExamplePanel.Children.Add(t);
gradientExamplePanel.Children.Add(b);
t = new System.Windows.Controls.TextBlock();
t.Text = "Desktop to Control";
b = new System.Windows.Controls.Button();
b.Width = 120;
b.Height = 20;
b.Background = new System.Windows.Media.RadialGradientBrush(System.Windows.SystemColors.DesktopColor, System.Windows.SystemColors.ControlColor);
gradientExamplePanel.Children.Add(t);
gradientExamplePanel.Children.Add(b);
}
}
}