PointerDownThemeAnimation应用程序停止WP8 [英] PointerDownThemeAnimation application stops WP8

查看:188
本文介绍了PointerDownThemeAnimation应用程序停止WP8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很困惑,为什么我的应用程序被关闭,我已经加入了PointerDownThemeAnimation,它工作正常,但只有一次,当我尝试再次单击它aplication停止。为什么结果
这里是我的代码:

 私人无效staryrynek1(对象发件人,PointerRoutedEventArgs E)
{
pointerDownStoryboard.Begin();
}

私人无效staryrynek(对象发件人,PointerRoutedEventArgs E)
{
pointerUpStoryboard.Begin();
this.Frame.Navigate(typeof运算(StaryRynek));
}

 <电网X:NAME =staryrynek_grid保证金=10,92,10,0VerticalAlignment =评出的PointerPressed =staryrynek1PointerReleased =staryrynek> 
< Grid.Resources>
<情节提要X:NAME =pointerDownStoryboard>
< PointerDownThemeAnimation的TargetName =staryrynek_grid/>
< /故事板>
<情节提要X:NAME =pointerUpStoryboard>
< PointerUpThemeAnimation的TargetName =staryrynek_grid/>
< /故事板>
< /Grid.Resources>
< Grid.Background>
<的SolidColorBrush颜色=黑不透明度=0.495/>
< /Grid.Background>
< TextBlock中的Horizo​​ntalAlignment =中心TextWrapping =包装VerticalAlignment =评出的WIDTH =380字号=29.333文本=施塔Rynek酒店/>
< /网格和GT;


解决方案

我觉得你找到一个真正的错误。 。这里的解决办法



XAML

 <电网> 
< Grid.Resources>
<情节提要X:NAME =PointerDownStory>
< PointerDownThemeAnimation的TargetName =MyRectangle/>
< /故事板>
<情节提要X:NAME =PointerUpStory>
< PointerUpThemeAnimation的TargetName =MyRectangle/>
< /故事板>
<风格的TargetType =矩形>
< setter属性=宽度值=300/>
< setter属性=高度值=200/>
< setter属性=填充VALUE =白/>
< /样式和GT;
< /Grid.Resources>
<矩形X:NAME =MyRectangle
PointerPressed =Grid_PointerPressed
PointerReleased =Grid_PointerReleased/>
< /网格和GT;



代码隐藏

 私人无效Grid_PointerPressed(对象发件人,PointerRoutedEventArgs E)
{
this.MyRectangle.Projection =新PlaneProjection();
PointerDownStory.Begin();
}

私人无效Grid_PointerReleased(对象发件人,PointerRoutedEventArgs E)
{
PointerUpStory.Begin();
}



这是 this.MyRectangle.Projection =新PlaneProjection (); 行你应该注意到。它是从原始代码的唯一真正的变化。好像 PointerUpThemeAnimation 无意中破坏了 PlaneProjection 。这都很正常,如果 PointerDownThemeAnimation 将重新创建它。



祝你好运!


I'm confused why my app is closing, I have added the PointerDownThemeAnimation and it works fine but only one time, when I try to click it again the aplication stops. Why?
Here is my code:

private void staryrynek1(object sender, PointerRoutedEventArgs e)
{
    pointerDownStoryboard.Begin();
}

private void staryrynek(object sender, PointerRoutedEventArgs e)
{
    pointerUpStoryboard.Begin();
    this.Frame.Navigate(typeof(StaryRynek));
}

and

<Grid x:Name="staryrynek_grid" Margin="10,92,10,0" VerticalAlignment="Top" PointerPressed="staryrynek1" PointerReleased="staryrynek">
        <Grid.Resources>
            <Storyboard x:Name="pointerDownStoryboard">
                <PointerDownThemeAnimation TargetName="staryrynek_grid" />
            </Storyboard>
            <Storyboard x:Name="pointerUpStoryboard">
                <PointerUpThemeAnimation TargetName="staryrynek_grid" />
            </Storyboard>
        </Grid.Resources>
        <Grid.Background>
            <SolidColorBrush Color="Black" Opacity="0.495"/>
        </Grid.Background>
        <TextBlock HorizontalAlignment="Center" TextWrapping="Wrap" VerticalAlignment="Top" Width="380" FontSize="29.333" Text="Stary Rynek"/>
    </Grid>

解决方案

I think you found a genuine bug. Here's the workaround.

XAML

<Grid>
    <Grid.Resources>
        <Storyboard x:Name="PointerDownStory">
            <PointerDownThemeAnimation TargetName="MyRectangle" />
        </Storyboard>
        <Storyboard x:Name="PointerUpStory">
            <PointerUpThemeAnimation TargetName="MyRectangle" />
        </Storyboard>
        <Style TargetType="Rectangle">
            <Setter Property="Width" Value="300" />
            <Setter Property="Height" Value="200" />
            <Setter Property="Fill" Value="White" />
        </Style>
    </Grid.Resources>
    <Rectangle x:Name="MyRectangle"
               PointerPressed="Grid_PointerPressed"
               PointerReleased="Grid_PointerReleased" />
</Grid>

Code-behind

private void Grid_PointerPressed(object sender, PointerRoutedEventArgs e)
{
    this.MyRectangle.Projection = new PlaneProjection();
    PointerDownStory.Begin();
}

private void Grid_PointerReleased(object sender, PointerRoutedEventArgs e)
{
    PointerUpStory.Begin();
}

It's the this.MyRectangle.Projection = new PlaneProjection(); line you should notice. It's the only real change from your original code. Seems like the PointerUpThemeAnimation inadvertently destroys the PlaneProjection. This would have been okay if the PointerDownThemeAnimation would re-create it.

Best of luck!

这篇关于PointerDownThemeAnimation应用程序停止WP8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆