Sketchflow - 加载时激活状态不起作用?

发布于 2024-08-20 20:57:54 字数 249 浏览 13 评论 0原文

我试图在屏幕加载时激活一个状态,但它不起作用。 我所做的是,转到屏幕,右键单击 LayoutRoot,然后转到“激活状态”,然后选择我的状态。然后,当我单击这个新生成的 [ActivateStateAction] 时,我将 EventName 从 MouseLeftButtonDown 更改为 Loaded。然而,它似乎不起作用。 MouseLeftButtonDown 有效,但 Loaded 无效。我在多个屏幕(不仅仅是启动屏幕)上尝试过此操作,但它仍然不起作用,有什么想法吗?

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 [ActivateStateAction] 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

月野兔 2024-08-27 20:57:54

我也有同样的问题。

我发现 ActivateStateAction Loaded 仅在我的第一个屏幕上被调用。然后我导航到的其他屏幕上的类似操作没有调用 Loaded 事件。

我将 ActivateStateAction 更改为在除第一个屏幕之外的所有屏幕上使用布局更新操作。当新屏幕更新布局时会触发此事件,现在我的问题已解决。

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.

南风几经秋 2024-08-27 20:57:54

我重复了你给出的步骤,它对我有用。你没有提到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>

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>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文