代码之家  ›  专栏  ›  技术社区  ›  Pickels

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

  •  0
  • Pickels  · 技术社区  · 14 年前

    我有一个组件屏幕,它有两种状态:显示和隐藏。当我单击某个按钮时,组件将移动到舞台上。现在,当您单击组件时,我希望它移回后台。对于普通元素,这可以通过使用激活状态来工作,但是对于组件屏幕,它似乎什么都不做。

    有人知道怎么解决这个问题吗?

    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>
    
    1 回复  |  直到 14 年前
        1
  •  0
  •   Chuck Hays    14 年前

    您可以发布组件屏幕的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>
    
    推荐文章