15.02.2015 Views

C# 4 and .NET 4

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

WPF ❘ ChaPTer 35 cOre wpf<br />

items Controls<br />

The ItemsControl class contains a list of items that can be accessed with the Items property. Classes that<br />

are derived from ItemsControl are shown in the following table.<br />

iTemsConTrol<br />

Menu ContextMenu<br />

StatusBar<br />

TreeView<br />

ListBox<br />

ComboBox<br />

TabControl<br />

DataGrid<br />

desCriPTion<br />

The classes Menu <strong>and</strong> ContextMenu are derived from the abstract base class<br />

MenuBase. You can offer menus to the user by placing MenuItem elements in the<br />

items list <strong>and</strong> associating comm<strong>and</strong>s.<br />

The StatusBar control is usually shown at the bottom of an application to give<br />

status information to the user. You can put StatusBarItem elements inside a<br />

StatusBar list.<br />

For a hierarchical display of items, you can use the TreeView control.<br />

ListBox, ComboBox, <strong>and</strong> TabControl have the same abstract base class,<br />

Selector. This base class makes it possible to select items from a list. The ListBox<br />

displays the items from a list. The ComboBox has an additional Button control<br />

to display the items only if the button is clicked. With TabControl, content can be<br />

arranged in tabular form.<br />

The DataGrid control is a customizable grid that displays data. This control is new<br />

with .<strong>NET</strong> 4 <strong>and</strong> is discussed in detail in the next chapter.<br />

headered items Controls<br />

HeaderedItemsControl is the base class of controls that include items but also has a header. The<br />

class HeaderedItemsControl is derived from ItemsControl.<br />

Classes that are derived from HeaderedItemsControl are listed in the following table.<br />

headerediTemsConTrol<br />

MenuItem<br />

TreeViewItem<br />

ToolBar<br />

desCriPTion<br />

The menu classes Menu <strong>and</strong> ContextMenu include items of the MenuItem<br />

type. Menu items can be connected to comm<strong>and</strong>s, as the MenuItem class<br />

implements the interface IComm<strong>and</strong>Source.<br />

The TreeView class can include items of type TreeViewItem.<br />

The ToolBar control is a container for a group of controls, usually<br />

Button <strong>and</strong> Separator elements. You can place the ToolBar inside a<br />

ToolBarTray that h<strong>and</strong>les rearranging of ToolBar controls.<br />

decoration<br />

Adding decorations to a single element is done<br />

with the Decorator class. Decorator is a base<br />

class that has derivations such as Border,<br />

Viewbox, <strong>and</strong> BulletDecorator. Theme elements<br />

such as ButtonChrome <strong>and</strong> ListBoxChrome are<br />

also decorators.<br />

The following example demonstrates a Border,<br />

Viewbox, <strong>and</strong> BulletDecorator, as in<br />

Figure 35-12.<br />

figure 35-12<br />

The Border class decorates the Children element by adding a border around it. You can define a brush <strong>and</strong><br />

the thickness of the border, the background, the radius of the corner, <strong>and</strong> the padding of its children:<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!