Nasıl yapılır: Düz Renk ile bir Alanı Boyama
Düz renge sahip bir alanı boyamak için veya gibi önceden tanımlanmış bir sistem fırçası kullanabilir veya yeni bir oluşturabilir ve alfa, kırmızı, yeşil ve mavi değerleri kullanarak bunu RedBlueSolidColorBrushColor açıklayın. XAML'de, hexidecimal notation kullanarak bir alanı düz renkle de boyayabilirsiniz.
Aşağıdaki örneklerde bu tekniklerin her biri mavi renkle Rectangle boyanmaktadır.
Örnek
Önceden Tanımlanmış Fırça Kullanma
Aşağıdaki örnekte dikdörtgen mavisi boyamak için önceden Blue tanımlanmış fırça kullanılır.
<Rectangle Width="50" Height="50" Fill="Blue" />
// Create a rectangle and paint it with
// a predefined brush.
Rectangle myPredefinedBrushRectangle = new Rectangle();
myPredefinedBrushRectangle.Width = 50;
myPredefinedBrushRectangle.Height = 50;
myPredefinedBrushRectangle.Fill = Brushes.Blue;
Onaltılık Notation Kullanma
Sonraki örnekte dikdörtgen maviye boyamak için 8 basamaklı onaltılık bir nota kullanılır.
<!-- Note that the first two characters "FF" of the 8-digit
value is the alpha which controls the transparency of
the color. Therefore, to make a completely transparent
color (invisible), use "00" for those digits (e.g. #000000FF). -->
<Rectangle Width="50" Height="50" Fill="#FF0000FF" />
ARGB Değerlerini Kullanma
Sonraki örnek bir oluşturur SolidColorBrush ve mavi renk için Color ARGB değerlerini kullanarak açıklar.
<Rectangle Width="50" Height="50">
<Rectangle.Fill>
<SolidColorBrush>
<SolidColorBrush.Color>
<!-- Describes the brush's color using
RGB values. Each value has a range of 0-255.
R is for red, G is for green, and B is for blue.
A is for alpha which controls transparency of the
color. Therefore, to make a completely transparent
color (invisible), use a value of 0 for Alpha. -->
<Color A="255" R="0" G="0" B="255" />
</SolidColorBrush.Color>
</SolidColorBrush>
</Rectangle.Fill>
</Rectangle>
Rectangle myRgbRectangle = new Rectangle();
myRgbRectangle.Width = 50;
myRgbRectangle.Height = 50;
SolidColorBrush mySolidColorBrush = new SolidColorBrush();
// Describes the brush's color using RGB values.
// Each value has a range of 0-255.
mySolidColorBrush.Color = Color.FromArgb(255, 0, 0, 255);
myRgbRectangle.Fill = mySolidColorBrush;
Rengi açıklamanın diğer yolları için yapıya Color bakın.
İlgili Konular
Ve ek örnekler hakkında daha fazla bilgi için Düz Renkler ve Gradyanlar ile Boyamaya SolidColorBrushSolidColorBrush bakın.
Bu kod örneği, sınıfı için sağlanan daha büyük bir örneğin bir SolidColorBrush parçasıdır. Tam örnek için bkz. Fırça Örneği.