1

私はwp7アプリを書いていますが、eventtriggerに1つの問題があります。このItemTemplateのリストボックスがあります。

            <DataTemplate>
                <Grid Name="templatePanel"  Width="200" Height="200" Margin="10">
                    <Grid.Triggers>
                        <EventTrigger RoutedEvent="Grid.Tap" >
                            <EventTrigger.Actions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="templatePanel"
                                 Storyboard.TargetProperty="Opacity"
                                 From="0"
                                 To="1"
                                 Duration="0:0:5"/>
                                    </Storyboard>
                                </BeginStoryboard>
                            </EventTrigger.Actions>
                        </EventTrigger>
                    </Grid.Triggers>
                <!--SOME KIND OF CONTENT-->
                </Grid>
            </DataTemplate>

アプリを実行すると、このStackTraceで不特定のエラーが発生してクラッシュします。

 at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
   at MS.Internal.XcpImports.UIElement_Measure(UIElement element, Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at Microsoft.Phone.Controls.WrapPanel.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Double inWidth, Double inHeight, Double& outWidth, Double& outHeight)
   at MS.Internal.XcpImports.MeasureNative(IntPtr element, Single inWidth, Single inHeight)
   at MS.Internal.XcpImports.UIElement_Measure(UIElement element, Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.ScrollContentPresenter.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Double inWidth, Double inHeight, Double& outWidth, Double& outHeight)
   at MS.Internal.XcpImports.MeasureNative(IntPtr element, Single inWidth, Single inHeight)
   at MS.Internal.XcpImports.UIElement_Measure(UIElement element, Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.ScrollViewer.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Double inWidth, Double inHeight, Double& outWidth, Double& outHeight)
   at MS.Internal.XcpImports.MeasureOverrideNative(IntPtr element, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
   at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
   at System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
   at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Double inWidth, Double inHeight, Double& outWidth, Double& outHeight)
   at MS.Internal.XcpImports.MeasureOverrideNative(IntPtr element, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
   at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
   at System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
   at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Double inWidth, Double inHeight, Double& outWidth, Double& outHeight)
   at MS.Internal.XcpImports.MeasureOverrideNative(IntPtr element, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
   at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
   at System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
   at Microsoft.Phone.Controls.PhoneApplicationFrame.MeasureOverride(Size availableSize)
   at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Double inWidth, Double inHeight, Double& outWidth, Double& outHeight)

しかし、私が設定した場合

<EventTrigger RoutedEvent="Grid.Loaded" >

アプリはクラッシュしません!

なぜそれが起こるのですか?少し早いですがお礼を!

4

1 に答える 1

1

SilverlightはLoadedRoutedEvent)のみをサポートします。MSDNからの引用:

XAMLでは、これを文字列として指定します。コードで、識別子(RoutedEvent値)を渡します。Silverlightでサポートされている値は、Loaded/FrameworkElement.LoadedEventのみです。

于 2013-03-22T21:09:44.347 に答える