Silverlight sketchflow:单击时组件屏幕更改状态

发布于 2024-09-24 15:11:56 字数 2050 浏览 3 评论 0原文

我有一个组件屏幕,有两种状态:显示和隐藏。当我单击某个按钮时,组件会移动到舞台上。现在,当您单击该组件时,我希望它移回舞台之外。对于普通元素,这通过使用激活状态来工作,但对于组件屏幕,它似乎没有做任何事情。

有人知道如何解决这个问题吗?

XML:

我的屏幕内的组件:

<local:googlemaps x:Name="googlemaps" Margin="97,0,97,-509" d:IsPrototypingComposition="True" Cursor="Hand" VerticalAlignment="Bottom" d:LayoutOverrides="Height" RenderTransformOrigin="0.5,0.5">
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="MouseLeftButtonDown">
            <pi:ActivateStateAction TargetState="hide"/>
        </i:EventTrigger>
    </i:Interaction.Triggers>
    <local:googlemaps.RenderTransform>
        <CompositeTransform/>
    </local:googlemaps.RenderTransform>
</local:googlemaps>

组件屏幕:

<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"
    xmlns:pc="http://schemas.microsoft.com/prototyping/2010/controls"
    mc:Ignorable="d"
    x:Class="EurekaScreens.googlemaps"
    d:DesignWidth="606" d:DesignHeight="480" Height="480" Width="606">

    <Grid x:Name="LayoutRoot">
        <Rectangle Fill="#FF212121" Margin="10,8,0,0" Stroke="Black"/>
        <Rectangle Fill="#FF212121" Margin="0,0,4,3" Stroke="Black" HorizontalAlignment="Right" Width="602"/>
        <Image Margin="1,1,5,4" Source="google maps.jpg" Stretch="Fill"/>
        <pc:SketchRectangleSL HorizontalAlignment="Right" Height="30" Margin="0,0,15,11" Style="{StaticResource Rectangle-Sketch}" VerticalAlignment="Bottom" Width="87"/>
        <TextBlock HorizontalAlignment="Right" Margin="0,0,36,13" Style="{StaticResource SubtitleLeft-Sketch}" TextWrapping="Wrap" Text="CLOSE" VerticalAlignment="Bottom" FontSize="18.667" Height="23" Width="44"/>
    </Grid>
</UserControl>

I have a component screen which has 2 states: show and hide. When I click some button the component moves onto the stage. Now when you click the component I want it to move back out of the stage. With normal elements this works by using activate state but with component screens it doesn't seem to do anything.

Anybody know how to solve this?

XML:

The component inside my screen:

<local:googlemaps x:Name="googlemaps" Margin="97,0,97,-509" d:IsPrototypingComposition="True" Cursor="Hand" VerticalAlignment="Bottom" d:LayoutOverrides="Height" RenderTransformOrigin="0.5,0.5">
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="MouseLeftButtonDown">
            <pi:ActivateStateAction TargetState="hide"/>
        </i:EventTrigger>
    </i:Interaction.Triggers>
    <local:googlemaps.RenderTransform>
        <CompositeTransform/>
    </local:googlemaps.RenderTransform>
</local:googlemaps>

The component screen:

<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"
    xmlns:pc="http://schemas.microsoft.com/prototyping/2010/controls"
    mc:Ignorable="d"
    x:Class="EurekaScreens.googlemaps"
    d:DesignWidth="606" d:DesignHeight="480" Height="480" Width="606">

    <Grid x:Name="LayoutRoot">
        <Rectangle Fill="#FF212121" Margin="10,8,0,0" Stroke="Black"/>
        <Rectangle Fill="#FF212121" Margin="0,0,4,3" Stroke="Black" HorizontalAlignment="Right" Width="602"/>
        <Image Margin="1,1,5,4" Source="google maps.jpg" Stretch="Fill"/>
        <pc:SketchRectangleSL HorizontalAlignment="Right" Height="30" Margin="0,0,15,11" Style="{StaticResource Rectangle-Sketch}" VerticalAlignment="Bottom" Width="87"/>
        <TextBlock HorizontalAlignment="Right" Margin="0,0,36,13" Style="{StaticResource SubtitleLeft-Sketch}" TextWrapping="Wrap" Text="CLOSE" VerticalAlignment="Bottom" FontSize="18.667" Height="23" Width="44"/>
    </Grid>
</UserControl>

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

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

发布评论

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

评论(1

海未深 2024-10-01 15:11:56

您可以发布组件屏幕的 xaml 以及包含它的屏幕吗?单击组件上的任意位置是否有效?我想它可能没有背景,所以不会收到点击事件。您可以尝试指定一个清晰的背景。

否则,请发布 xaml,我会看看是否可以提供帮助。

我不完全确定为什么,但由于某种原因,鼠标按下事件似乎没有达到该行为。当我将组件屏幕包裹在网格中并将行为放在网格上时,它似乎工作正常:

<Grid HorizontalAlignment="Right" Margin="0,-2,-625,2" Width="606" Background="#00000000">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="MouseLeftButtonUp">
                    <pi:ActivateStateAction TargetState="hide"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
            <local:Screen_2 x:Name="screen_2" Height="480" Width="606" d:IsPrototypingComposition="True" RenderTransformOrigin="0.5,0.5">
                <local:Screen_2.RenderTransform>
                    <CompositeTransform/>
                </local:Screen_2.RenderTransform>
            </local:Screen_2>
        </Grid>

Could you post the xaml for the component screen, and the screen containing it? Does it work to click anywhere on the component? I am thinking possibly that it has no background so doesn't receive click events. You could try assigning a background that is clear.

Otherwise, post the xaml and I'll see if I can help.

I'm not entirely sure why, but for some reason it seems like the mouse down event isn't getting to the behavior. When I wrap the component screen in a grid, and put the behavior on a grid, it seems to work properly:

<Grid HorizontalAlignment="Right" Margin="0,-2,-625,2" Width="606" Background="#00000000">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="MouseLeftButtonUp">
                    <pi:ActivateStateAction TargetState="hide"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
            <local:Screen_2 x:Name="screen_2" Height="480" Width="606" d:IsPrototypingComposition="True" RenderTransformOrigin="0.5,0.5">
                <local:Screen_2.RenderTransform>
                    <CompositeTransform/>
                </local:Screen_2.RenderTransform>
            </local:Screen_2>
        </Grid>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文