These controls have both a content
region and a header region, which can be used to display some sort of title. These controls
include GroupBox, TabItem (a page in a TabControl), and Expander.
nNote Figure 5-1 leaves out very little. It doesn??™t show the Frame element that??™s used for content navigation
(Chapter 9), and it omits a few elements that are used inside other controls (such as list box and status
bar items).
The Content Property
Whereas the Panel class adds the Children collection to hold nested elements, the Content-
Control class adds a Content property, which accepts a single object. The Content property
supports any type of object, but it separates objects into two groups and gives each group
different treatment:
??? Objects that don??™t derive from UIElement. The content control calls ToString() to get
the text for these controls and then displays that text.
??? Objects that derive from UIElement. These objects (which include all the visual
elements that are a part of WPF) are displayed inside the content control using the
UIElement.OnRender() method.
nNote Technically, the OnRender() method doesn??™t draw the object immediately??”it simply generates a
graphical representation that WPF paints on the screen as needed.
To understand how this works, consider the humble button.
Pages:
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260