15.02.2015 Views

C# 4 and .NET 4

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Templates ❘ 1011<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

code snippet TriggerDemo/DataTriggerWindow.xaml<br />

In the code-behind, the list with the name list1 is initialized to contain several Book objects:<br />

public DataTriggerWindow()<br />

{<br />

InitializeComponent();<br />

list1.Items.Add(new Book<br />

{<br />

Title = "Professional <strong>C#</strong> 4.0",<br />

Publisher = "Wrox Press"<br />

});<br />

list1.Items.Add(new Book<br />

{<br />

Title = "<strong>C#</strong> 2008 for Dummies",<br />

Publisher = "Dummies"<br />

});<br />

list1.Items.Add(new Book<br />

{<br />

Title = "Mastering Integrated HTML <strong>and</strong> CSS",<br />

Publisher = "Sybex"<br />

});<br />

}<br />

Running the application, you can see in Figure 35-21 the ListBoxItem<br />

elements that are formatted according to the publisher value.<br />

With DataTrigger, multiple properties must be set for MultiDataTrigger<br />

(similar to Trigger <strong>and</strong> MultiTrigger).<br />

TemPlaTes<br />

code snippet TriggerDemo/DataTriggerWindow.xaml.cs<br />

figure 35-21<br />

In this chapter, you have already seen that a Button control can have any content. The content can be<br />

simple text, but you can also add a Canvas element, which can contain shapes. You can add a Grid, or a<br />

video to the button. However, there is even more than that you can do with a button!<br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!