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.

3 - D ❘ 1029<br />

< /VisualStateGroup.Transitions ><br />

< /VisualStateGroup ><br />

< /VisualStateManager.VisualStateGroups ><br />

< Border x:Name="border1" BorderThickness="12" ><br />

< Border.BorderBrush ><br />

< SolidColorBrush x:Name="brush1" Color="White" / ><br />

< /Border.BorderBrush ><br />

< Image x:Name="image1" / ><br />

< /Border ><br />

< /Button ><br />

< /Grid ><br />

< /DockPanel ><br />

< /Window ><br />

code snippet VisualStateDemo/MainWindow.xaml<br />

With the Click events, the Button elements in the StackPanel h<strong>and</strong>lers from code - behind are invoked.<br />

Within code - behind the GoToElementState() method of the VisualStateManager is invoked to change<br />

the button1 object to a new state. The third argument of this method defi nes whether the transition<br />

changing to this state should be invoked:<br />

private void OnSleeping(object sender, RoutedEventArgs e)<br />

{<br />

VisualStateManager.GoToElementState(button1, "Sleeping", true);<br />

}<br />

private void OnPlaying(object sender, RoutedEventArgs e)<br />

{<br />

VisualStateManager.GoToElementState(button1, "Playing", true);<br />

}<br />

private void OnCrying(object sender, RoutedEventArgs e)<br />

{<br />

VisualStateManager.GoToElementState(button1, "Crying", true);<br />

}<br />

After running the application you can see the<br />

state changes as shown in Figure 35 - 34.<br />

c o d e s n i p p e t V i s u a l S t a t e D e m o / M a i nW i n d o w. x a m l . c s<br />

3 - d<br />

The last section in this large chapter gives<br />

you an introduction to the 3 - D features of<br />

WPF. Here you ’ ll fi nd the information to<br />

get started.<br />

figure 35-34<br />

The namespace for 3-D with WPF is System.Windows.Media.Media3D.<br />

To underst<strong>and</strong> 3 - D with WPF it is important to know the difference between the coordination systems.<br />

Figure 35 - 35 shows the WPF 3 - D coordination system. The origin is placed in the center. The x - axis has<br />

positive values to the right <strong>and</strong> negative values to the left. The y - axis is vertical with positive values up <strong>and</strong><br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!