Prev | Current Page 350 | Next

Matthew MacDonald

"Pro WPF with VB 2008: Windows Presentation Foundation with .NET 3.5"

It includes a set of standard RGB properties (A, R, G,
and B) and a set of properties for scRGB (ScA, ScR, ScG, and ScB). These properties are linked, so that if you
set the R property, the ScR property is changed accordingly.
The relationship between the RGB values and the scRGB values is not linear. A 0 value in the RGB system
is 0 in scRGB, 255 in RGB becomes 1 in scRGB, and all values in between 0 and 255 in RGB are
represented as decimal values in between 0 and 1 in scRGB.
Setting Colors in XAML
When you set the background or foreground in XAML, you can use a helpful shortcut. Rather
than define a Brush object, you can supply a color name or color value. The WPF parser will
automatically create a SolidColorBrush object using the color you specify, and it will use that
brush object for the foreground or background. Here??™s an example that uses a color name:

It??™s equivalent to this more verbose syntax:

You need to use the longer form if you want to create a different type of brush, such as a
LinearGradientBrush, and use that to paint the background.
If you want to use a color code, you need to use a slightly less convenient syntax that
puts the R, G, and B values in hexadecimal notation.


Pages:
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362