导航

WinRT应用触摸崩溃的问题(已解决)

Posted on 2013-01-21 09:58  Bullatus  阅读(431)  评论(0)    收藏  举报

此问题已有解决方法,参见

http://www.cnblogs.com/bullatus/archive/2013/01/22/2871469.html

 

之前的一篇文章写了我遇到的Metro应用启用动画崩溃的问题。

当时这的是莫名其妙的感觉,目前已经能够重现了。

使用如下代码

View Code
<Page
    x:Class="FunctionTest.BlankPage1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:FunctionTest"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    <Page.Resources>
        <Storyboard x:Name="FloatingFlipOver">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.GlobalOffsetZ)" Storyboard.TargetName="FloatingRoot">
                <EasingDoubleKeyFrame KeyTime="0" Value="-2000"/>
                <EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="0">
                    <EasingDoubleKeyFrame.EasingFunction>
                        <QuarticEase/>
                    </EasingDoubleKeyFrame.EasingFunction>
                </EasingDoubleKeyFrame>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="FloatingRoot">
                <EasingDoubleKeyFrame KeyTime="0" Value="180"/>
                <EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="0">
                    <EasingDoubleKeyFrame.EasingFunction>
                        <QuarticEase/>
                    </EasingDoubleKeyFrame.EasingFunction>
                </EasingDoubleKeyFrame>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="FloatingRoot">
                <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="1"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
    </Page.Resources>

    <Grid>        
        <Grid x:Name="FloatingRoot" Visibility="Collapsed" Width="500" Height="300">
            <Grid.Projection>
                <PlaneProjection  CenterOfRotationX="0.5" CenterOfRotationY="0.5"/>
            </Grid.Projection>
            <Rectangle x:Name="FloatingBackground" Fill="SkyBlue" />
            <FlipView>
                <Grid x:Name="FloatingContainer" Width="300" Height="300">
                    
                </Grid>
            </FlipView>
        </Grid>
        <Button Content="Test" HorizontalAlignment="Left" Margin="46,36,0,0" VerticalAlignment="Top" Click="Test_Click"/>
    </Grid>
</Page>
        private void Test_Click(object sender, RoutedEventArgs e)
        {
            Button msiBtn = new Button();
            msiBtn.Content = "addBtn";
            msiBtn.Width = 100; msiBtn.Height = 50;
            msiBtn.Tapped += msiBtn_Tapped;
            FloatingContainer.Children.Add(msiBtn);
            FloatingRoot.Opacity = 0;
            FloatingRoot.Visibility = Visibility.Visible;
            FloatingFlipOver.Begin();
        }

        void msiBtn_Tapped(object sender, TappedRoutedEventArgs e)
        {
            FloatingRoot.Visibility = Visibility.Collapsed;
            FloatingContainer.Children.Clear();
        }

 使用鼠标则不会有任何问题,如果使用触摸,则会在关闭时使应用down掉。