संपादित (मैं उसे स्वत: अपडेट के लिए इच्छुक के लिए खाते में नहीं था):
यहाँ एक 'टिकर' वर्ग के a link है कि INotifyProperty का उपयोग करता है ताकि यह स्वतः अपडेट हो जाए।
namespace TheJoyOfCode.WpfExample
{
public class Ticker : INotifyPropertyChanged
{
public Ticker()
{
Timer timer = new Timer();
timer.Interval = 1000; // 1 second updates
timer.Elapsed += timer_Elapsed;
timer.Start();
}
public DateTime Now
{
get { return DateTime.Now; }
}
void timer_Elapsed(object sender, ElapsedEventArgs e)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("Now"));
}
public event PropertyChangedEventHandler PropertyChanged;
}
}
<Page.Resources>
<src:Ticker x:Key="ticker" />
</Page.Resources>
<TextBox Text="{Binding Source={StaticResource ticker}, Path=Now, Mode=OneWay}"/>
प्रचार:
xmlns:sys="clr-namespace:System;assembly=mscorlib"
अब इस काम करेगा:
<TextBox Text="{Binding Source={StaticResource ticker}, Path=Now, Mode=OneWay}"/>
स्रोत
2010-07-28 16:00:09
गलत। यह मदद नहीं करेगा। (यह वही है जो उसने लिखा था) – SLaks
और वह क्यों काम नहीं करेगा? –
क्योंकि यह अभी भी अपडेट नहीं होगा। प्रश्न फिर से पढ़ें। – SLaks