<TextBox Height="41" Text="{Binding CurrentDateTime}"
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace WpfApplication9{public partial class Timer {private Timer clockTimer;public Timer();{clockTimer = new Timer(1000);clockTimer.Elapsed += new ElapsedEventHandler(clockTimer_Elapsed);clockTimer.Start();DataContext = this;}void clockTimer_Elapsed(object sender, ElapsedEventArgs e){Dispatcher.BeginInvoke(new Action(UpdateCurrentDateTime));} public string CurrentDateTime{get { return (string)GetValue(CurrentDateTimeProperty); }set { SetValue(CurrentDateTimeProperty, value); }}public static readonly DependencyProperty CurrentDateTimeProperty =DependencyProperty.Register("CurrentDateTime", typeof(string), typeof(Mainwindow), new UIPropertyMetadata(string.Empty));private void UpdateCurrentDateTime(){CurrentDateTime = DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss");}}