silverlight右下角定时弹窗,模拟信息报警


silverlight使用定时器右下角定时弹窗,模拟信息报警。



代码如下:

<Canvas VerticalAlignment="Bottom" HorizontalAlignment="Right">
        
        <Canvas.Resources>
            <Storyboard x:Name="storyPopUp">
                <DoubleAnimation Duration="0:0:2" From="0" To="-200" Storyboard.TargetName="canvasPopup" Storyboard.TargetProperty="(Canvas.Top)" />
            </Storyboard>
            <Storyboard x:Name="storyPopDown">
                <DoubleAnimation Duration="0:0:2" From="-200" To="0" Storyboard.TargetName="canvasPopup" Storyboard.TargetProperty="(Canvas.Top)" />
            </Storyboard>
        </Canvas.Resources>
        <Canvas VerticalAlignment="Bottom" HorizontalAlignment="Right" x:Name="canvasPopup" Margin="-200 0 0 0" Width="200" Height="200">
            <Border BorderThickness="1,1,1,1" Background="Azure" HorizontalAlignment="Right" VerticalAlignment="Top"
                    BorderBrush="Gold" Width="200" Height="200">
                <Border.Effect>
                    <DropShadowEffect />
                </Border.Effect>
                
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="15" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>

                    <TextBlock Text="学习右下角弹窗" FontSize="12" FontWeight="Black" Foreground="Black" Grid.Row="0" />
                    <Border Background="White" Margin="0 5 0 0" CornerRadius="5" Grid.Row="1">
                        <TextBlock Text="弹窗显示内容!" Margin="3" TextWrapping="Wrap" FontSize="12" Width="190" />
                    </Border>
                </Grid>
            </Border>
        </Canvas>
    </Canvas>

 

后台代码:

System.Windows.Threading.DispatcherTimer gapTimer;


 void initAlarmTimer()
        {
            gapTimer = new System.Windows.Threading.DispatcherTimer();
            gapTimer.Interval = new TimeSpan(0, 0, 0, 10);
            gapTimer.Tick += new EventHandler(gapTimer_Tick);
            gapTimer.Start();
        }


        void gapTimer_Tick(object sender, EventArgs e)
        {
            popAlarm();
        }
        #region 报警信息


        private void popAlarm()
        {
            storyPopUp.Begin();
            alarmTitle.Text = "报警类型";
            alarmContent.Text = "警情明细" + DateTime.Now.ToLongTimeString();
            System.Windows.Threading.DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer();
            timer.Interval = new TimeSpan(0, 0, 0, 0, 4500);
            timer.Tick += new EventHandler((sender2, e2) =>
            {
                storyPopUp.Stop();
                storyPopDown.Begin();
                timer.Stop();
            });
            timer.Start();
        }

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值