Current Time Not working in WPF DLL

Posted by Anu on Stack Overflow See other posts from Stack Overflow or by Anu
Published on 2010-05-29T05:16:56Z Indexed on 2010/05/29 5:22 UTC
Read the original article Hit count: 366

Filed under:
|
|

HI, I making one DLL in WPF,C# and im using it in VC++.In that DLL, ihave one textblock to display current time,But when i run the WPF application as WIndows application it shows current time correctly and also updated with new timings.But when i use it as Dll in VC++ applcation,the current time is not get updating.It shows the time when the applcaiton is loaded.thats all.Its not get updated. Code:

public Button()
        {
            InitializeComponent();
            DispatcherTimer dispatcherTimer = new DispatcherTimer();
            dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
            dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
            dispatcherTimer.Start();
        }
        private void dispatcherTimer_Tick(object sender, EventArgs e)
        {      
            DataContext = DateTime.Now.ToString("g");                      

        }

XAML:

<TextBlock Margin="0,6,211,0" Name="textBlock1" Text="{Binding}"/>

© Stack Overflow or respective owner

Related posts about c#

Related posts about wpf