Timer in StatusBar

  1. we need to show local time in StatusBar. solution: 1. add textblock control 2. binding to a string. 3. we use dispatcherTimer class to update the string.
  2. DispatcherTimer class
  3. Code Example:

XAML:

    <StatusBarItem HorizontalAlignment="Left" Margin="10,0,0,0">
<TextBlock Text="当前时间: " />
</StatusBarItem>
<StatusBarItem HorizontalAlignment="Left">
<TextBlock Text="{Binding CurrentTime}" />
</StatusBarItem>

c#:

        public string CurrentTime
{
get
{
return _currentTime;
}
set
{
_currentTime = value;
RaisePropertyChanged("");
}
}
private void UpdateTime( object sender, EventArgs e)
{
CurrentTime = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString();
}
timer = new DispatcherTimer();
timer.Interval = new TimeSpan(0,0,1);
timer.Tick += new EventHandler(UpdateTime);
timer.Start();

Timer Design in StatusBar的更多相关文章

  1. 关于StatusStrip控件和StatusBar控件的小试

    今天,在网上查找资料,突然看到一个例子,但例子中提及的StatusBar控件,我发现在vs控件压根不存在,我就郁闷了,于是上网查找才知道,现在这个控件已经被StatusStrip控件给吞了,Statu ...

  2. [nRF51822] 4、 图解nRF51 SDK中的Schedule handling library 和Timer library

    :nRF51822虽然是一个小型的单片机,但是能真正达到任意调用其官方驱动以及BLE协议栈的人还是奇缺的.据我所见,大都拿官方给的一个冗长的蓝牙低功耗心率计工程改的.之前我对于这个工程进行log跟踪, ...

  3. Design Pattern: Observer Pattern

    1. Brief 一直对Observer Pattern和Pub/Sub Pattern有所混淆,下面打算通过这两篇Blog来梳理这两种模式.若有纰漏请大家指正. 2. Use Case 首先我们来面 ...

  4. React Native组件之ScrollView 和 StatusBar和TabBarIos

    React Native中的组件ScrollView类似于iOS中的UIScrollView,其基本的使用方法和熟悉如下: /** * Sample React Native App * https: ...

  5. Microsecond and Millisecond C# Timer[转]

    文章转至:http://www.codeproject.com/Articles/98346/Microsecond-and-Millisecond-NET-Timer IntroductionAny ...

  6. can't able to update the design capacity in bq27441-G1

    /*************************************************************************** * can't able to update ...

  7. .NET System.Timers.Timer的原理和使用(开发定时执行程序)

    概述(来自MSDN) Timer 组件是基于服务器的计时器,它使您能够指定在应用程序中引发Elapsed 事件的周期性间隔.然后可以操控此事件以提供定期处理.例如,假设您有一台关键性服务器,必须每周7 ...

  8. Android Material Design NavigationView 及 Palette 颜色提取器

    DrawerLayout + NavigationView DrawerLayout布局,通常在里面添加两个子控件,程序主界面添加到NavitagionView前面. <android.supp ...

  9. A WPF/MVVM Countdown Timer

    Introduction This article describes the construction of a countdown timer application written in C# ...

随机推荐

  1. angular 页面加载时可以调用 函数处理

    转载于 作者:海底苍鹰地址:http://blog.51yip.com/jsjquery/1599.html 我希望页面加载的时候,我能马上处理页面的数据,如请求API .... 所以这样设置 在某个 ...

  2. mongodb replica set(副本集)设置步骤

    网上已经有一大堆的设置步骤的了,根据我遇到的问题,整理一下,如下: 首先先去下载一个mongodb最新版,目前最新版应该是2.6 cd /usr/local/bin wget http://fastd ...

  3. ios NSString常见的字符串操作 分割 查找

    1.NSString *str = [[NSString alloc]init];     //简单粗暴,基本用不到 2.NSString *str = [[NSString alloc]initWi ...

  4. File Manager文件管理应用android源码

    这个刚刚在安卓教程网那里看到的,File Manager文件管理应用android源码,这个是File Manager文件管理应用源码,源码filemanager,一个开源的文件管理器完整源码,文件查 ...

  5. jquery 读取xml

    <script type="text/javascript" src="jquery/jquery-1.11.3.min.js"></scri ...

  6. Unable to write inside TEMP environment path

    安装PostgreSQL 9:Unable to write inside TEMP environment path 注册表:regedit HKEY_CLASSES_ROOT\.vbs,设置默认为 ...

  7. 返回json格式时间,解析时间

    传入:Json格式的时间 JS如下: yyyy-M(MM)-d(dd) H(HH):m(mm):s(ss) function timeStamp2String(time) { var data=tim ...

  8. php怎么删除文件

    php怎么删除文件 删除文件很简单只要使用unlink(文件名)就可以了.

  9. ViewPager中GridView问题

    GridView 嵌套在ViewPager中问题. 1. GridView属性设置无法显示. 正常显示方式 <GridView android:padding="8dip" ...

  10. 在ASP.NET MVC中以post方式传递数组参数的示例

    最近在工作中用到了在ASP.NET MVC中以post方式传递数组参数的情况,记录下来,以供参考. 一.准备参数对象 在本例中,我会传递两个数组参数:一个字符串数组,一个自定义对象数组.这个自定义对象 ...