Predefined brush in Brushes Class : Brush « Windows Presentation Foundation « C# / C Sharp






Predefined brush in Brushes Class

Predefined brush in Brushes 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,0,0,5">
        Predefined Brush in the Brushes class:
      </TextBlock>
      <Rectangle x:Name="rect1" Width="100" Height="30"
        Stroke="Blue" />

    </StackPanel>
  </Canvas>
</Window>
//File:Window.xaml.cs

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Shapes;


namespace WpfApplication1
{
    public partial class SolidColorBrushExample : Window
    {
        public SolidColorBrushExample()
        {
            InitializeComponent();
            SolidColorBrush brush = new SolidColorBrush();
            // Predefined brush in Brushes Class: 
            brush = Brushes.Red;
            rect1.Fill = brush;

        }

    }
}

   
    
  








Related examples in the same category

1.Set color for SolidColorBrushSet color for SolidColorBrush
2.Paint with system brushes and colors.Paint with system brushes and colors.
3.Uses a predefined SolidColorBrush, defined by the System.Windows.Media.Brushes classUses a predefined SolidColorBrush, defined by the System.Windows.Media.Brushes class
4.Gradient brushes within a DrawingBrush. Two overlapping gradients are layeredGradient brushes within a DrawingBrush. Two overlapping gradients are layered
5.OpacityMask, LinearGradientBrush, RenderTransform
6.Brush resourceBrush resource
7.Use a VisualBrush to magnify a portion of the screen.Use a VisualBrush to magnify a portion of the screen.
8.Solid Color Brush In Code with predefined brushSolid Color Brush In Code with predefined brush
9.Solid Color Brush In Code with SolidColorBrushSolid Color Brush In Code with SolidColorBrush
10.Solid Color Brush In Code with SolidColorBrush and RGB colorSolid Color Brush In Code with SolidColorBrush and RGB color