Solved

How to bind WPF control to datetime.now()

Posted on 2010-09-19
1
917 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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 remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now