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.

Controls ❘ 997<br />

headeredConTenTConTrol<br />

Exp<strong>and</strong>er<br />

GroupBox<br />

TabItem<br />

desCriPTion<br />

With the Exp<strong>and</strong>er control, you can create an “advanced” mode with<br />

a dialog box that, by default, does not show all information but that<br />

can be exp<strong>and</strong>ed by the user to show more information. In the<br />

unexp<strong>and</strong>ed mode, header information is shown. In exp<strong>and</strong>ed mode, the<br />

content is visible.<br />

The GroupBox control provides a border <strong>and</strong> a header to group controls.<br />

TabItem controls are items within the class TabControl. The Header<br />

property of the TabItem defi nes the content of the header shown with<br />

the tabs of the TabControl.<br />

A simple use of the Exp<strong>and</strong>er control is shown in the next example. The Exp<strong>and</strong>er control has the property<br />

Header set to Click for more . This text is displayed for expansion. The content of this control is shown<br />

only if the control is exp<strong>and</strong>ed. Figure 35 - 10 shows the application with a collapsed Exp<strong>and</strong>er control.<br />

Figure 35 - 11 shows the same application with an exp<strong>and</strong>ed Exp<strong>and</strong>er control:<br />

< Window x:Class="Exp<strong>and</strong>erDemo.MainWindow"<br />

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"<br />

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"<br />

Title="Exp<strong>and</strong>er Demo" Height="240" Width="500" ><br />

< StackPanel ><br />

< TextBlock > Short information < /TextBlock ><br />

< Exp<strong>and</strong>er Header="Additional Information" ><br />

< Border Height="200" Width="200" Background="Yellow" ><br />

< TextBlock HorizontalAlignment="Center"<br />

VerticalAlignment="Center" ><br />

More information here!<br />

< /TextBlock ><br />

< /Border ><br />

< /Exp<strong>and</strong>er ><br />

< /StackPanel ><br />

< /Wi n d o w ><br />

code snippet Exp<strong>and</strong>erDemo/MainWindow.xaml<br />

To make the header text of the Exp<strong>and</strong>er control change when the control is exp<strong>and</strong>ed,<br />

you can create a trigger. Triggers are explained later in this chapter.<br />

figure 35-10 figure 35-11<br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!