Solved

How to bind WPF control to datetime.now()

Posted on 2010-09-19
1
921 Views
Last Modified: 2012-05-10

Hi,

Just wondering how I would go about binding a WPF control to time.now.seconds (for example) so that it updates when the seconds property changes. I have it binding on initialization, but it does not update the UI as the property changes:


Dim MySourceProperty As New Binding("Second")
        MySourceProperty.Source = DateTime.Now
        MySourceProperty.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
        MySourceProperty.Mode = BindingMode.OneWay
        TextBlock1.SetBinding(TextBlock1.TextProperty, MySourceProperty)

Open in new window

0
Comment
Question by:satellite428
1 Comment
 
LVL 29

Accepted Solution

by:
Gautham Janardhan earned 500 total points
ID: 33710886
wont work.. if you need you txt block to get updated, u will need a timer and then call the binding refresh every second.. or create  custom property which returns DateTime.Now.Seconds and then call the property change of the property in a timer.

I dont think we can do this without a timer.(Using the story board is an option but that will be an over kill)
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question