我正在将我的应用程序迁移到UWP,我发现了一个问题。那是当我长按或在列表视图中按住某个项目时,应用程序将崩溃并退出。我已经尝试自己处理Holding
事件。但它不起作用。执行我注册的OnHolding
事件并在其中不执行任何操作后,它只是退出而没有任何跟踪(我不能使用F10一步一步地调试它,它只是退出而没有任何信息)。任何的想法?这只发生在Win10手机中。
private void OnHolding(object sender, HoldingRoutedEventArgs e)
{
e.Handled = true;
}
ShowLayout.Execute()
的代码 public object Execute(object sender, object parameter)
{
FrameworkElement senderElement = sender as FrameworkElement;
FlyoutBase flyoutBase = FlyoutBase.GetAttachedFlyout(senderElement);
flyoutBase.ShowAt(senderElement);
return null;
}
这是关于Flyout项目的xaml代码
<FlyoutBase.AttachedFlyout>
<MenuFlyout
Closed="OnFlyoutClosed"
Opening="OnFlyoutOpening">
<MenuFlyout.MenuFlyoutPresenterStyle>
<Style
TargetType="MenuFlyoutPresenter">
<Setter Property="RequestedTheme" Value="Light"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="MenuFlyoutPresenter">
<Border x:Name="OuterBorder" FlowDirection="LeftToRight" BorderBrush="Transparent">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="PlacementStates">
<VisualState x:Name="None" />
<VisualState x:Name="TopPortrait">
<Storyboard>
<PointAnimation Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="RenderTransformOrigin" Duration="0:0:0" To="0,1" />
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="OuterBorder" Storyboard.TargetProperty="BorderThickness">
<DiscreteObjectKeyFrame KeyTime="0" Value="0,0,0,1.5" />
<DiscreteObjectKeyFrame KeyTime="0:0:0.50" Value="{ThemeResource MenuFlyoutPortraitBorderThemeThickness}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="CenterBorder" Storyboard.TargetProperty="BorderThickness">
<DiscreteObjectKeyFrame KeyTime="0" Value="0,0,0,1.5" />
<DiscreteObjectKeyFrame KeyTime="0:0:0.50" Value="{ThemeResource MenuFlyoutPortraitBorderThemeThickness}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ItemsPresenter" Storyboard.TargetProperty="Margin">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource MenuFlyoutPortraitThemePadding}" />
</ObjectAnimationUsingKeyFrames>
<DoubleAnimation Storyboard.TargetName="OuterScaleTransform" Storyboard.TargetProperty="ScaleX" Duration="0:0:0.38" From="0.0" To="1.0" />
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="InnerScaleTransform" Storyboard.TargetProperty="ScaleY">
<LinearDoubleKeyFrame KeyTime="0:0:0" Value="0.0" />
<LinearDoubleKeyFrame KeyTime="0:0:0.38" Value="0.0" />
<LinearDoubleKeyFrame KeyTime="0:0:0.50" Value="1.0" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="BottomPortrait">
<Storyboard>
<PointAnimation Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="RenderTransformOrigin" Duration="0:0:0" To="0,1" />
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="OuterBorder" Storyboard.TargetProperty="BorderThickness">
<DiscreteObjectKeyFrame KeyTime="0" Value="0,0,0,1.5" />
<DiscreteObjectKeyFrame KeyTime="0:0:0.50" Value="{ThemeResource MenuFlyoutPortraitBorderThemeThickness}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="CenterBorder" Storyboard.TargetProperty="BorderThickness">
<DiscreteObjectKeyFrame KeyTime="0" Value="0,0,0,1.5" />
<DiscreteObjectKeyFrame KeyTime="0:0:0.50" Value="{ThemeResource MenuFlyoutPortraitBorderThemeThickness}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ItemsPresenter" Storyboard.TargetProperty="Margin">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource MenuFlyoutPortraitThemePadding}" />
</ObjectAnimationUsingKeyFrames>
<DoubleAnimation Storyboard.TargetName="OuterScaleTransform" Storyboard.TargetProperty="ScaleX" Duration="0:0:0.38" From="0.0" To="1.0" />
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="InnerScaleTransform" Storyboard.TargetProperty="ScaleY">
<LinearDoubleKeyFrame KeyTime="0:0:0" Value="0.0" />
<LinearDoubleKeyFrame KeyTime="0:0:0.38" Value="0.0" />
<LinearDoubleKeyFrame KeyTime="0:0:0.50" Value="1.0" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="LeftLandscape">
</VisualState>
<VisualState x:Name="RightLandscape">
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Border.RenderTransform>
<ScaleTransform x:Name="OuterScaleTransform" />
</Border.RenderTransform>
<Border x:Name="CenterBorder" Margin="12" FlowDirection="LeftToRight" BorderBrush="{StaticResource XX.ColorBrush.WG}" BorderThickness="2.5">
<StackPanel x:Name="InnerBorder" FlowDirection="{TemplateBinding FlowDirection}" Background="{TemplateBinding Background}">
<StackPanel.RenderTransform>
<ScaleTransform x:Name="InnerScaleTransform" />
</StackPanel.RenderTransform>
<ItemsPresenter x:Name="ItemsPresenter" Margin="{TemplateBinding Padding}" FlowDirection="{TemplateBinding FlowDirection}" />
</StackPanel>
</Border>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</MenuFlyout.MenuFlyoutPresenterStyle>
<MenuFlyoutItem
Click="xx"
Text="{Binding xx" />
<MenuFlyoutItem .../>
</MenuFlyout>
</FlyoutBase.AttachedFlyout>