Silverlight 中的滑动弹出窗口

发布于 2024-12-01 08:52:45 字数 112 浏览 3 评论 0原文

当用户将鼠标悬停在某个控件上时,我需要在 Silverlight 4.0 中实现一个弹出窗口。并且弹出窗口应该从控件中滑出。我可以显示一个弹出窗口。但无法为其提供滑动效果。请帮帮我。

提前致谢。

I've one requirement to implement a popup in Silverlight 4.0 when user hovers mouse over some control. And the popup should slide out from the control. I can show a popup. But can't give a sliding effect to it. Please help me out.

Thanks in advance.

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

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

发布评论

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

评论(1

少年亿悲伤 2024-12-08 08:52:45

我一直在使用带有阴影的矩形来滑动类型“弹出窗口”。如果您需要模态类型,您可以禁用背景。

这是使用纯 xaml,但故事板可以从代码隐藏中调用。

参考交互性

   xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
 xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" x:Class="SomeProject"

我正在使用导航页面,因此滑入和滑出转换的代码如下所示。

 <navigation:Page.Resources>
        <Storyboard x:Name="Storyboard_Enter">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="rectangle">
                <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                <EasingDoubleKeyFrame KeyTime="0:0:2" Value="520"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Name="Storyboard_GoBack">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="rectangle">
                <SplineDoubleKeyFrame KeyTime="0" Value="520"/>
                <SplineDoubleKeyFrame KeyTime="0:0:2" Value="0"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
    </navigation:Page.Resources>

LayoutRoot

 <Grid x:Name="LayoutRoot">
        <Button x:Name="btnEnter" Content="Enter" HorizontalAlignment="Left" Height="48" Margin="96,88,0,0" VerticalAlignment="Top" Width="144">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="MouseEnter" SourceName="btnEnter">
                    <ei:ControlStoryboardAction Storyboard="{StaticResource Storyboard_Enter}"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </Button>
        <Rectangle x:Name="rectangle" Fill="#FF393939" Margin="-376,232,0,72" Stroke="Black" RadiusY="25" RadiusX="21" HorizontalAlignment="Left" Width="358" RenderTransformOrigin="0.5,0.5">
            <Rectangle.RenderTransform>
                <CompositeTransform/>
            </Rectangle.RenderTransform>
            <Rectangle.Effect>
                <DropShadowEffect BlurRadius="15" Color="#FFBABABA"/>
            </Rectangle.Effect>
        </Rectangle>
        <Button x:Name="btnGoBack" Content="Exit" Height="48" Margin="296,88,192,0" VerticalAlignment="Top">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="MouseEnter" SourceName="btnGoBack">
                    <ei:ControlStoryboardAction Storyboard="{StaticResource Storyboard_GoBack}"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </Button>

    </Grid>

这是一个非常粗略的示例,但应该可以帮助您入门。

我们将“弹出”容器放置在主画布边缘的视图之外。

创建故事板以将其滑入和滑回。

可以使用基于 xaml 的触发器或从代码隐藏来调用故事板。

I've been using rectangles with a drop shadow for sliding type "popups". You can disable the background if you need a modal type.

This is using pure xaml but the storyboards can be called from codebehind.

Reference to interactivity

   xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
 xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" x:Class="SomeProject"

I'm using navigation pages so my code for the slide in and out transitions look as follows.

 <navigation:Page.Resources>
        <Storyboard x:Name="Storyboard_Enter">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="rectangle">
                <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                <EasingDoubleKeyFrame KeyTime="0:0:2" Value="520"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Name="Storyboard_GoBack">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="rectangle">
                <SplineDoubleKeyFrame KeyTime="0" Value="520"/>
                <SplineDoubleKeyFrame KeyTime="0:0:2" Value="0"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
    </navigation:Page.Resources>

The LayoutRoot

 <Grid x:Name="LayoutRoot">
        <Button x:Name="btnEnter" Content="Enter" HorizontalAlignment="Left" Height="48" Margin="96,88,0,0" VerticalAlignment="Top" Width="144">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="MouseEnter" SourceName="btnEnter">
                    <ei:ControlStoryboardAction Storyboard="{StaticResource Storyboard_Enter}"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </Button>
        <Rectangle x:Name="rectangle" Fill="#FF393939" Margin="-376,232,0,72" Stroke="Black" RadiusY="25" RadiusX="21" HorizontalAlignment="Left" Width="358" RenderTransformOrigin="0.5,0.5">
            <Rectangle.RenderTransform>
                <CompositeTransform/>
            </Rectangle.RenderTransform>
            <Rectangle.Effect>
                <DropShadowEffect BlurRadius="15" Color="#FFBABABA"/>
            </Rectangle.Effect>
        </Rectangle>
        <Button x:Name="btnGoBack" Content="Exit" Height="48" Margin="296,88,192,0" VerticalAlignment="Top">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="MouseEnter" SourceName="btnGoBack">
                    <ei:ControlStoryboardAction Storyboard="{StaticResource Storyboard_GoBack}"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </Button>

    </Grid>

This is a very crude example but should get you started.

We have the "popup" container sitting out of view right on the very edge of the main canvas.

Create storyboards to slide it in and slide it back.

Storyboards can be called with xaml based triggers or from codebehind.

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