Create a nice Navigation Flip in Silverlight3
2009-09-16 13:46
197 查看
1. Add Navigation assembly in the application and import the namespace for the assembly.
xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
2. In this sample, you have to create 4 pages, Page1.xaml, Page2.xaml, Page3.xaml, Page4.xaml under the folder Views.
2. defiine the xaml code
3. write the code behind
xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
2. In this sample, you have to create 4 pages, Page1.xaml, Page2.xaml, Page3.xaml, Page4.xaml under the folder Views.
2. defiine the xaml code
<UserControl x:Class="FlipPages3D.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation" mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"> <Grid x:Name="LayoutRoot" Background="Black"> <Grid.RowDefinitions> <RowDefinition Height="50" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <StackPanel Orientation="Horizontal" Background="Gray" Grid.Row="0" Grid.Column="0"> <HyperlinkButton Content="Page1" Tag="/Views/Page1.xaml" Background="White" Width="100" Height="30" HorizontalAlignment="Center" VerticalAlignment="Center" Click="HyperlinkButton_Click" /> <HyperlinkButton Content="Page2" Tag="/Views/Page2.xaml" Background="White" Width="100" Height="30" HorizontalAlignment="Center" VerticalAlignment="Center" Click="HyperlinkButton_Click" /> <HyperlinkButton Content="Page3" Tag="/Views/Page3.xaml" Background="White" Width="100" Height="30" HorizontalAlignment="Center" VerticalAlignment="Center" Click="HyperlinkButton_Click" /> <HyperlinkButton Content="Page4" Tag="/Views/Page4.xaml" Background="White" Width="100" Height="30" HorizontalAlignment="Center" VerticalAlignment="Center" Click="HyperlinkButton_Click" /> </StackPanel> <StackPanel Grid.Row="1" Grid.Column="0" Background="Wheat"> <StackPanel.Projection> <PlaneProjection x:Name="mainPanelProjection" /> </StackPanel.Projection> <StackPanel.Resources> <Storyboard x:Name="FlipStart"> <DoubleAnimation From="0" To="90" Duration="00:00:1" Completed="Flip1Half_Completed" Storyboard.TargetName="mainPanelProjection" Storyboard.TargetProperty="RotationY"> </DoubleAnimation> </Storyboard> <Storyboard x:Name="FlipEnd"> <DoubleAnimation From="270" To="360" Duration="00:00:1" Storyboard.TargetName="mainPanelProjection" Storyboard.TargetProperty="RotationY"> <DoubleAnimation.EasingFunction> <BackEase EasingMode="EaseOut" /> </DoubleAnimation.EasingFunction> </DoubleAnimation> </Storyboard> </StackPanel.Resources> <navigation:Frame x:Name="MainFrame" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="20" Source="/Views/Page1.xaml" /> </StackPanel> </Grid> </UserControl>
3. write the code behind
public partial class MainPage : UserControl { HyperlinkButton menuClicked = null; public MainPage() { InitializeComponent(); } private void HyperlinkButton_Click(object sender, RoutedEventArgs e) { menuClicked = sender as HyperlinkButton; if (MainFrame.Source.ToString() != menuClicked.Tag.ToString()) FlipStart.Begin(); } void Flip1Half_Completed(object sender, EventArgs e) { if (menuClicked != null) MainFrame.Navigate(new Uri(menuClicked.Tag.ToString(), UriKind.Relative)); FlipEnd.Begin(); } }
相关文章推荐
- How to create custom navigation menu in SharePoint with XML data source 使用XML数据源在SharePoint创建自定义导航菜单
- How to create custom navigation menu in SharePoint with XML data source 使用XML数据源在SharePoint创建自定义导航菜单
- unable to create new native thread&You have mail in /var/spool/mail/root
- unable to create new native thread&You have mail in /var/spool/mail/root
- QObject: Cannot create children for a parent that is in a different thread
- Create Rich Text Features in iOS with Text Kit
- Hadoop Cannot create file Name node is in safe mode
- 【Qt】Qt出现QObject: Cannot create children for a parent that is in a different thread.问题
- How to create a Gantt chart in SharePoint
- Could not find goal 'create' in plugin org.apache.maven.plugins:maven-archetype-plugin:3.0.0 among
- Combining Navigation Drawer with ViewPager and TabLayout in one screen
- iOS Xcode 更新7.3 connot create __weak reference in file using manual reference counting
- Pricing In SAP SD - Create New Condition Types and Procedure
- SQL Server 在多个数据库中创建同一个存储过程(Create Same Stored Procedure in All Databases)
- Create vitual directory in asp.net
- How to Create Mysite in SharePoint 2010
- Create and Call HttpHandler in SharePoint
- Dynamics CRM2016 Web API之Create related entities in one operation
- create module in actionscript project
- [Angular] Create a custom validator for template driven forms in Angular