windows-8 – 触摸时FlipView崩溃
发布时间:2020-12-14 05:27:19 所属栏目:Windows 来源:网络整理
导读:在 Windows应用商店中 XAML 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://sche
在
Windows应用商店中
XAML <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" 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(); } 当与鼠标一起使用时, 解决方法
我认为你的意思是崩溃,而不是崩溃,对吗?因为这就是我所看到的.
有一个与ScrollViewers和投影相关的已知错误.我不确定它是否是公开讨论的,但我听说在WinRT XAML Toolkit(在FlipAnimation中)对我有用的解决方法之一似乎也适用于你的情况,因为FlipView有一个ScrollViewer作为其模板的一部分.基本上你需要将ScrollViewer的ZoomMode更改为其他内容并返回,然后它可以正常运行而不会崩溃.为了修复代码片段中的代码,我引用了WinRT XAML Toolkit来使用VisualTreeHelperExtensions来帮助提取ScrollViewer并在动画完成后来回更改ZoomMode,如下所示: using WinRTXamlToolkit.Controls.Extensions; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Input; namespace App96 { public sealed partial class MainPage : Page { public MainPage() { this.InitializeComponent(); } 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(); FloatingFlipOver.Completed -= FloatingFlipOver_Completed; FloatingFlipOver.Completed += FloatingFlipOver_Completed; } void FloatingFlipOver_Completed(object sender,object e) { foreach (var sv in FloatingRoot.GetDescendantsOfType<ScrollViewer>()) { sv.ZoomMode = (ZoomMode)(((int)sv.ZoomMode + 1) % 2); sv.ZoomMode = (ZoomMode)(((int)sv.ZoomMode + 1) % 2); } } void msiBtn_Tapped(object sender,TappedRoutedEventArgs e) { FloatingRoot.Visibility = Visibility.Collapsed; FloatingContainer.Children.Clear(); } } } VisualTreeHelperExtensions的相关位,如果您不需要整个Toolkit,可以使用它: public static class VisualTreeHelperExtensions { public static IEnumerable<T> GetDescendantsOfType<T>(this DependencyObject start) where T : DependencyObject { return start.GetDescendants().OfType<T>(); } public static IEnumerable<DependencyObject> GetDescendants(this DependencyObject start) { var queue = new Queue<DependencyObject>(); var count = VisualTreeHelper.GetChildrenCount(start); for (int i = 0; i < count; i++) { var child = VisualTreeHelper.GetChild(start,i); yield return child; queue.Enqueue(child); } while (queue.Count > 0) { var parent = queue.Dequeue(); var count2 = VisualTreeHelper.GetChildrenCount(parent); for (int i = 0; i < count2; i++) { var child = VisualTreeHelper.GetChild(parent,i); yield return child; queue.Enqueue(child); } } } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- windows – 如何解析NIC服务ID(GUID)?
- group-policy – 管理Windows 8开始屏幕平铺
- 如何在Windows上使用ImageMagick命令行?
- 获取Windows XP的管理员访问权限(丢失密码)
- .net – 如何显示混合模式程序集的版本号是Windows资源管理
- Windows.event未定义 – Firefox中的JavaScript错误
- windows – 用户和内核之间的线程fs段寄存器切换
- 联想拯救者Y7000安装双系统:win10 + ubuntu16.04 (GTX106
- environment variable is too large 2047
- 如何解决Windows 8游戏的触摸输入延迟?
推荐文章
站长推荐
热点阅读