Mega Code Archive

 
Categories / C# / WPF
 

From sRGB values in the Color strutcure

<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,10,0,5">         From sRGB value in the Color structure:       </TextBlock>       <Rectangle x:Name="rect3" 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();             // From sRGB values in the Color strutcure:              brush = new SolidColorBrush(Color.FromArgb(100, 0, 0, 255));             rect3.Fill = brush;         }     } }