gpt4 book ai didi

c# - PointerDownThemeAnimation 应用程序停止 WP8

转载 作者:行者123 更新时间:2023-11-30 16:59:13 28 4
gpt4 key购买 nike

我很困惑为什么我的应用程序会关闭,我添加了 PointerDownThemeAnimation 并且它工作正常但只有一次,当我再次尝试单击它时应用程序停止了。为什么?
这是我的代码:

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

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

<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>

最佳答案

我认为您发现了一个真正的错误。这是解决方法。

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>

代码隐藏

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();
}

这是您应该注意的 this.MyRectangle.Projection = new PlaneProjection(); 行。这是您原始代码的唯一真正变化。似乎 PointerUpThemeAnimation 无意中破坏了 PlaneProjection。如果 PointerDownThemeAnimation 会重新创建它,那就没问题了。

祝你好运!

关于c# - PointerDownThemeAnimation 应用程序停止 WP8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24023458/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com