博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
DispatcherTimer 当前时间
阅读量:7183 次
发布时间:2019-06-29

本文共 1312 字,大约阅读时间需要 4 分钟。

hot3.png

<UserControl x:Class="DispatcherTimerDome.MainPage"

    xmlns=""
    xmlns:x="
"
    xmlns:d="
"
    xmlns:mc="
"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <Grid x:Name="LayoutRoot" Background="White">

        <StackPanel >
            <Border Background="DarkCyan" Width="400" Height="300" BorderBrush="Red" BorderThickness="5" CornerRadius="10" >
                <TextBlock Name="tbName" FontSize=" 24"  Width="200" Height="200" >
                </TextBlock>
            </Border>
          
        </StackPanel>
       
    </Grid>
</UserControl>

=============================================================================================================

using System;

using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Threading;

namespace DispatcherTimerDome

{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
            DispatcherTimer timer = new DispatcherTimer();
            timer.Interval = new TimeSpan(0, 0, 1);
            timer.Tick += new EventHandler(timer_Tick);
            timer.Start();
           
            
        }

        void timer_Tick(object sender, EventArgs e)

        {
            tbName.Text = DateTime.Now.ToLongTimeString();
        }
    }
}

 

原文链接:

转载于:https://my.oschina.net/changpinghu/blog/92581

你可能感兴趣的文章
[saiku] 简化/汉化/设置默认页
查看>>
使用nginx搭建https服务器(转)
查看>>
Hibernate注解
查看>>
[转]World Wind Java开发之四——搭建本地WMS服务器
查看>>
3D数学基础:四元数与欧拉角之间的转换
查看>>
算法导论:二叉搜索树
查看>>
【译】Spring 4 自动装配、自动检测、组件扫描示例
查看>>
使用VS Code从零开始开发调试.NET Core 1.1
查看>>
openssl req 证书请求及自签名证书
查看>>
《linux 内核全然剖析》编译linux 0.12 内核 Ubuntu 64bits 环境
查看>>
路由器不重启,是否ip就永远不变
查看>>
安卓数据传递之---putextra与putextras
查看>>
【后会有期】
查看>>
Codeforces Round #346 (Div. 2) - D Bicycle Race
查看>>
nginx php上传大小设置
查看>>
spring原理机制
查看>>
Oracle分析函数-nulls first/nulls last
查看>>
Python中时间类解决类似朋友圈时间显示的小问题
查看>>
NodeJs针对Express框架配置Mysql进行数据库操作
查看>>
基于MNIST数据集使用TensorFlow训练一个没有隐含层的浅层神经网络
查看>>