Prev | Current Page 360 | Next

Matthew MacDonald

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


In the Control class, the Foreground property uses inheritance. The Background property does
not. However, the default background is a null reference (Nothing) that??™s rendered by most controls
as a transparent background. (That means the parent??™s background will show through, as
shown in Figure 7-1.) In the UIElement class, AllowDrop, IsEnabled, and IsVisible use property
inheritance. In the FrameworkElement, the CultureInfo and FlowDirection properties do.
nNote A dependency property supports inheritance only if the FrameworkPropertyMetadata.Inherits flag
is set to True, which is not the default. Chapter 6 discusses the FrameworkPropertyMetadata class and
property registration in detail.
CHAPTER 7 n CLASSIC CONTROLS 190
Font Substitution
When you??™re setting fonts, you need to be careful to choose a font that you know will be present
on the user??™s computer. However, WPF does give you a little flexibility with a font fallback
system. You can set FontFamily to a comma-separated list of font options. WPF will then move
through the list in order, trying to find one of the fonts you??™ve indicated.
Here??™s an example that attempts to use Technical Italic font but falls back to Comic Sans
MS or Arial if that isn??™t available:

If a font family really does contain a comma in its name, you??™ll need to escape the comma
by including it twice in a row.


Pages:
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372