画面がロードされたときに状態をアクティブにしようとしていますが、機能しません。私がしていることは、画面に移動し、LayoutRoot を右クリックしてから、[Activate State] に移動し、自分の状態を選択することです。次に、この新しく生成された [ActivateStateAction] をクリックすると、EventName が MouseLeftButtonDown から Loaded に変更されます。しかし、うまくいかないようです。MouseLeftButtonDown は機能しますが、Loaded は機能しません。(起動画面だけでなく)複数の画面でこれを試しましたが、まだ機能しません。何かアイデアはありますか?
1078 次
2 に答える
2
私も同じ問題を抱えていました。
ActivateStateAction Loaded が最初の画面でのみ呼び出されることがわかりました。その後ナビゲートした他の画面での同様のアクションは、Loaded イベントを呼び出していませんでした。
最初の画面を除くすべての画面で、ActivateStateAction を Layout Updated アクションに使用するように変更しました。このイベントは、新しい画面がレイアウトを更新したときに発生し、問題が修正されました。
于 2010-10-13T19:42:13.710 に答える
1
あなたが与えた手順を繰り返しましたが、うまくいきました。SL や WPF について言及がなかったので、Silverlight で試してみました。activatestateaction のプロパティをチェックして、ターゲットの状態名が正しいことを確認してください。それでも問題が解決しない場合はお知らせください。問題を見つけるお手伝いをします (xaml を投稿してください)。私のアクションによって生成されたxamlは次のとおりです。
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:pb="clr-namespace:Microsoft.Expression.Prototyping.Behavior;assembly=Microsoft.Expression.Prototyping.Interactivity"
x:Class="SilverlightPrototype2Screens.Screen_1"
Width="640" Height="480">
<Grid x:Name="LayoutRoot" Background="White">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Loaded">
<pb:ActivateStateAction TargetScreen="SilverlightPrototype2Screens.Screen_1" TargetState="VisualState"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="VisualStateGroup">
<VisualState x:Name="VisualState">
<Storyboard>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
<EasingColorKeyFrame KeyTime="00:00:00" Value="Red"/>
</ColorAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Rectangle x:Name="rectangle" Fill="White" Stroke="Black" Height="74" HorizontalAlignment="Left" Margin="171,116,0,0" VerticalAlignment="Top" Width="107" RenderTransformOrigin="0.5,0.5">
<Rectangle.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</Rectangle.RenderTransform>
</Rectangle>
</Grid>
于 2010-02-05T17:36:59.650 に答える