开发者

Sketchflow - activating state on loaded doesn't work?

开发者 https://www.devze.com 2022-12-19 10:45 出处:网络
I\'m trying to activate a state when the screen is loaded but it doesn\'t work. What I do is, I go to the screen, right click the LayoutRoot and then go \"Activate State\" and I pick my state. Then wh

I'm trying to activate a state when the screen is loaded but it doesn't work. What I do is, I go to the screen, right click the LayoutRoot and then go "Activate State" and I pick my state. Then when I click on this newly generated [开发者_如何学PythonActivateStateAction] I change the EventName from MouseLeftButtonDown to Loaded. However, it doesn't seem to work. The MouseLeftButtonDown works but not the Loaded. I tried this on multiple screens (not just the startup screen) but it still doesn't work, any ideas?


I had the same problem.

I found out the ActivateStateAction Loaded, was only called for my first screen. Similar actions on other screens which I then navigated to weren't calling the Loaded event.

I changed my ActivateStateAction to use to Layout Updated action on all screen but the first. This event is fired when a new screen updates the layout and now my problem is fixed.


I repeated the steps you gave and it worked for me. You didn't mention SL or WPF, so I tried it in Silverlight. Maybe check the properties of the activatestateaction to be sure the target state name is correct. Let me know if you still can't get it working and I can try to help find the problem (post your xaml). Here is the xaml generated by my actions:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号